next up previous contents index
Next: Java Up: Jar Previous: Nested elements   Contents   Index

Examples

  <jar destfile="${dist}/lib/app.jar" basedir="${build}/classes"/>
jars all files in the ${build}/classes directory into a file called app.jar in the $dist/lib directory.
  <jar destfile="${dist}/lib/app.jar"
       basedir="${build}/classes"
       excludes="**/Test.class"
  />
jars all files in the ${build}/classes directory into a file called app.jar in the $dist/lib directory. Files with the name Test.class are excluded.
  <jar destfile="${dist}/lib/app.jar"
       basedir="${build}/classes"
       includes="mypackage/test/**"
       excludes="**/Test.class"
  />
jars all files in the ${build}/classes directory into a file called app.jar in the $dist/lib directory. Only files under the directory mypackage/test are used, and files with the name Test.class are excluded.
  <jar destfile="${dist}/lib/app.jar">
    <fileset dir="${build}/classes"
             excludes="**/Test.class"
    />
    <fileset dir="${src}/resources"/>
  </jar>
jars all files in the ${build}/classes directory and also in the
\$\{src\}/resources directory togethe...
...ctory. Files with the name Test.class are excluded. If
there are files such as $build/classes/mypackage/MyClass.class and ${src}/resources/mypackage/image.gif, they will appear in the same directory in the JAR (and thus be considered in the same package by Java).
  <jar destfile="test.jar" basedir=".">
    <include name="build"/>
    <manifest>
      <attribute name="Built-By" value="${user.name}"/>
      <section name="common/class1.class">
        <attribute name="Sealed" value="false"/>
      </section>
    </manifest>
  </jar>
This is an example of an inline manifest specification. Note that the Built-By attribute will take the value of the Ant property ${user.name}. The manifest produced by the above would look like this:
Manifest-Version: 1.0
Built-By: conor
Created-By: Apache Ant 1.5alpha

Name: common/class1.class
Sealed: false



Andrew Marlow 2003-07-08