Reputation: 325
I am trying to create Jar file using ANT. I have couple of java-classes inside folder named My-Classes. I also have 1 Jar files inside that folder My-Classes (ABC.jar).
I want to include all classes from folder My-Classes in newly created jar. Along with that I want to include only 2 classes which are present in ABC.jar, in my newly create Jar file
Note Abc.jar has many classes inside it.
I simply want ANT to scan JAR file & include only 2 specified class files in newly created JAR.
Currently it only include classes from com/mypackage/testApp/ package
<jar jarfile=${dist.lib}/test/testApp.jar>
<fileset dir=My-Classes includes=com/mypackage/testApp/**/>
<fileset dir=My-Classes includes=com/abc/Bundle.class,com/abc/Work.class/>
</jar>
Upvotes: 0
Views: 71
Reputation: 122364
You need to use a zipfileset
rather than a plain fileset
to extract entries from one JAR and add them to another.
<jar destfile="${dist.lib}/test/testApp.jar">
<!-- all .class files from under the My-Classes directory -->
<fileset dir="My-Classes" includes="**/*.class" />
<!-- two specific classes from out of My-Classes/ABC.jar -->
<zipfileset src="My-Classes/ABC.jar"
includes="com/abc/Bundle.class,com/abc/Work.class" />
</jar>
Upvotes: 1