![](/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.