简体   繁体   中英

How to include libs and other non class folders in a project while creating a jar file using <jar> task in build.xml

In my project I can include packages under src folder, but I need to include other folders (which don't contains .java or .class files) and libraries.

How do I include libraries and other non class folders in a project while creating a jar file using <jar> task in my build.xml ?

Here's a snapshot of how I do this:

<jar destfile="adasim-${version}-deps.jar" manifest="resources/MANIFEST.MF">
                        <fileset dir="${class.dir}"/>
                        <fileset dir=".">
                                <include name="resources/xml/adasim.xsd"/>
                                <include name="resources/VERSION"/>
                        </fileset>
                        <archives>
                                <zips>
                                        <fileset dir="${lib.dir}" includes="**/*.jar" excludes="**/junit*.jar"/>
                                </zips>
                        </archives>
 </jar>

you use <fileset> to select files that you want to copy into the JAR and you use <zips> combined with JARs to include that contents from JARs.

Extensive documentation can be found in the ant manual .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM