Need ANT task to include jar file set in final jar / lib file

There is a bunch of dependent jars in my project folder:

/lib/someapi-1.1.1/main.jar /lib/someotherapi-2.2.2/api-2.2.2.jar /lib/... 

I create a JAR file, and my application requires that dependent bans be included in the final jar in the / lib folder in the jar, so the last jar should have a structure like:

 /org/me/myclasses.class /lib/main.jar /lib/api-2.2.2.jar 

How to get / lib / * .jar files smoothed included in the / lib directory of my last jar file?


EXPLANATION

I'm just trying to get a set of resource files, flattened and added to this directory in my last bank.

+4
source share
2 answers

The easiest way I see is to copy allyour jars to a temporary folder using the copy task and its flatten attribute and include the banks of this temporary directory in the target jar.


ADDED DETAILS added by user

Here's the final goal of ANT (for future reference):

  <target name="dist"> <mkdir dir="${classes}/lib"/> <copy flatten="true" todir="${classes}/lib" includeemptydirs="false"> <fileset dir="lib"> <include name="**/*.jar" /> </fileset> </copy> <jar destfile="${dist}/MyOneBigJar.jar"> <fileset dir="${classes}"/> </jar> </target> 
+3
source

If you want, skip the copy step, you can do it this way. It uses <mappedresources> to smooth out the source lib directories in the / lib class area.

 <jar destfile="${dist}/MyOneBigJar.jar"> <fileset dir="${classes}"/> <mappedresources> <fileset dir="lib"> <include name="**/*.jar" /> </fileset> <chainedmapper> <flattenmapper /> <globmapper from="*" to="classes/lib/*" /> </chainedmapper> </mappedresources> </jar> 
+4
source

Source: https://habr.com/ru/post/1479219/


All Articles