1

I have been researching trying to find a way to combine multiple Jar files into on Jar as a deliverable.

In a directory I have an ant file named Jar_gen.xml that consists of the following code in its entirety

<target name="combine-jars">
    <jar destfile="out.jar">
        <zipgroupfileset dir="lib" includes="*.jar"/>
    </jar>
</target>

In that same directory I have another directory named lib which contains all of the Jar files I would like to flatten.

I have been running the ant script with

ant -buildfile Jar_gen.xml

making sure that I am running it from the same directory that the Jar_gen.xml file is in.

I am getting no output from my ant script and I have not idea why. Can someone please help me fix my script so I may flatten all of my jars and continue constructing my deliverable package.

NOTE

I have no main class so the Eclipse runnable Jar will not work for me

I have very little experience running Ant scripts so complete answers would be very helpful.

JME
  • 2,293
  • 9
  • 36
  • 56
  • http://stackoverflow.com/questions/3770071/including-external-jar-files-in-a-new-jar-file-build-with-ant http://stackoverflow.com/questions/1821803/creating-a-bundle-jar-with-ant try this ones – smajlo Sep 24 '13 at 18:16

1 Answers1

4

Is your directory structure set up correctly?

I created a quick test using your script and it appears to work, given that you have everything set up in a directory structure as

project_root_dir
- build.xml
- lib
  - a.jar
  - b.jar

and build.xml looks like:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project name="test">
    <target name="combine-jars">
        <jar destfile="out.jar">
            <zipgroupfileset dir="lib" includes="*.jar"/>
        </jar>
    </target>
</project>

when I go to the project_root_dir and run "ant combine-jars", I get an out.jar that contains the contents of both a.jar and b.jar.

Mark
  • 4,970
  • 5
  • 42
  • 66
  • This answer is correct I was missing the xml header and the project tags, also my command line invocation was wrong and I needed to add the target name. – JME Sep 24 '13 at 18:23