Given an Ant path element like the following one:
<path id="compile.classpath">
<pathelement location="${common.jar}"/>
<pathelement location="${servlet.jar}"/>
<pathelement location="${j2ee.jar}"/>
...
</path>
How can I create an uber-jar that includes all the files in the path without having to spell out all the file names again? The following works, but contains duplicate code, and is not what I want:
<jar jarfile="uber.jar" ...>
<manifest> ... </manifest>
<zipfileset src="${common.jar}"/> // UNWANTED code duplication
<zipfileset src="${servlet.jar}"/>
<zipfileset src="${j2ee.jar}"/>
</jar>
You should be able to do this:
I don’t understand why the
common.jarwould have unwanted duplicate code. Also, you normally don’t include jars inside a jar.I think what you really want to create is a War File. A war file can contain multiple jars, plus the classes you want to execute (the ones you compiled via the
<javac>task). In the META-INF/MANIFEST.MF file, you include aMain-Class:entry pointing to the class that should be the entry point of your war. Users will be able to execute your war as: