Using jarbundler ant task to add dependencies to the app

363 Views Asked by At

I have a Netbeans Java project. When I build my project it create a directory dist and dist/lib. It stores the Jar of the file in dist and other jar files on which the main jar file depends, in the lib directory.

Now I want to create a release for OSX. For that I am using the jarbundler ant task like this

<target name="mac">
        <mkdir dir="release"/>
        <taskdef name="jarbundler"
        classname="net.sourceforge.jarbundler.JarBundler" />
        <jarbundler dir="release"
            name="MyApp"
            mainClass="controller.MyApp"
            jar="dist/MyApp.jar" />
</target>

This creates the app with the jar, but how do I add the dependent libraries to the app.

1

There are 1 best solutions below

2
On BEST ANSWER

This is what is needed

The jar attribute should be replaced with jarfileset like this.

<target name="mac">
      <mkdir dir="release"/>
      <taskdef name="jarbundler"
               classname="net.sourceforge.jarbundler.JarBundler" />

               <jarbundler dir="release"
                           name="MyApp"
                           mainClass="controller.MyApp">
                      <jarfileset dir="dist">
                          <include name="**/*.jar" />
                      </jarfileset>
               </jarbundler>
</target>