![](/img/trans.png)
[英]How to include the jars referenced in “Java Build Path” section of an Eclipse project in a jar file generated with Ant using a build.xml file
[英]How to include an XML file into the root of a jar using Ant script?
使用Ant創建.jar存檔時出現以下問題。
在Eclipse中,我有一個名為AtmosAdampter的項目,並且有以下Ant腳本創建了atmosadapter.jar文件:
<?xml version="1.0"?>
<project default="default">
<!-- ============================================ -->
<!-- Load build properties -->
<!-- ============================================ -->
<property name="project.buildfile" value="../../../../../CrystalIceGUI/Project/build.num" />
<property file="${project.buildfile}" />
<property file="../../../../../CrystalIceGUI/Project/info.properties" />
<!-- ============================================ -->
<!-- Specify the classpath -->
<!-- ============================================ -->
<path id="project.classpath">
<fileset dir="../../../../../SharedLib/">
<include name="**/*.jar" />
</fileset>
</path>
<!-- ============================================ -->
<!-- The default target -->
<!-- ============================================ -->
<target name="default" depends="jar" />
<!-- Elimina le cartelle contenenti le classi compilate ed i jar -->
<target name="clean">
<echo message="Into AtmosAdapter build.xml clean target" />
<!-- <delete dir="../../Release" /> -->
<delete file="../../Release/*.jar" />
<!-- Elimina directory del jar finale -->
<delete dir="bin" />
<!-- Elimina directory delle classi compilate -->
</target>
<target name="compile" depends="clean">
<echo message="Into AtmosAdapter build.xml compile target" />
<mkdir dir="bin" />
<javac srcdir="src" destdir="bin" classpathref="project.classpath" />
</target>
<target name="jar" description="Packs classes of AtmosAdapter" depends="compile">
<jar destfile="../../Release/atmosadapter.jar" index="false">
<fileset dir="bin" />
<manifest>
<attribute name="Created-By" value="${info.software.author}" />
</manifest>
</jar>
</target>
</project>
問題是,在Eclipse AtmosAdapter項目中,我在src文件夾中有一個settings.xml文件。
因此,進入Eclipse,該項目具有以下結構:
AtmosAdapter ---> src ---> settings.xml
問題在於,使用先前的Ant腳本,我沒有將settings.xml文件放入.jar文件的根目錄中。
我該怎么做還要插入此文件?
<jar>
任務可以使用多個<fileset>
:
<jar destfile="../../Release/atmosadapter.jar" index="false">
<fileset dir="bin" />
<fileset dir="src" includes="settings.xml" />
<manifest>
<attribute name="Created-By" value="${info.software.author}" />
</manifest>
</jar>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.