Ant Task - nsoft/uno-jar GitHub Wiki

The ant task has been updated to be usable as an antlib. An example of how to use it can be seen here:

https://github.com/nsoft/uno-jar/blob/master/build.xml

Parts to note:

<project name="uno-jar" default="testAntTask" basedir="." xmlns:ns="antlib:com.needhamsoftware.unojar.ant">

  <path id="unojar.lib.path">
    <fileset dir="ant/build" includes="libs/*.jar"/>
  </path>

  <taskdef uri="antlib:com.needhamsoftware.unojar.ant"
           classpathref="unojar.lib.path" resource="com/needhamsoftware/unojar/antlib.xml"/>

This demonstrates how to install the taskdef without modifying the base ant distro (by adding the jar to the ant distro's lib directory). However it should also be possible to use this in any other way supported by Apache Ant.

   <ns:unojar destfile="${basedir}/build/test.jar"  >
      <ns:main>
        <fileset refid="test.files"/>
      </ns:main>
      <ns:manifest>
        <attribute name="Uno-Jar-Main-Class" value="com.needhamsoftware.unojar.TestMain"/>
      </ns:manifest>
      <ns:lib>
        <fileset dir="build" includes="libTest.jar"/>
      </ns:lib>
    </ns:unojar>

The above demonstrates the 3 parts of the ant task presently supported.

  • main - specifies the primary class files and classpath resources for your application. Anything specified here will be packed into main/main.jar within the final jar file.
  • lib - specifies the jar files to be included as dependencies. These will land in lib/ within the final jar file
  • manifest - Specifies attributes to be added to the top level manifest of the jar file. Specifying the Uno-Jar-Main-Class is almost always what you want and it should point to the class with a public static void main(String[] args) method that is the entry point for your application

Disclaimer

One-JAR had a couple other sections, and though they might still work, this is not tested or maintained presently. If you want to resurrect a feature from One-JAR or if you want to rely on something that seems to have not yet broken, you can either create a fork, or file an issue here and offer to maintain the feature.

⚠️ **GitHub.com Fallback** ⚠️