@@ -426,34 +426,39 @@ depend on your manifest:</p>
<h3>Examples</h3>
<h3>Examples</h3>
<pre> <jar destfile="${dist}/lib/app.jar" basedir="${build}/classes"/></pre>
<h4>Simple</h4>
<blockquote><pre> <jar destfile="${dist}/lib/app.jar" basedir="${build}/classes"/></pre></blockquote>
<p>jars all files in the <code>${build}/classes</code> directory into a file
<p>jars all files in the <code>${build}/classes</code> directory into a file
called <code>app.jar</code> in the <code>${dist}/lib</code> directory.</p>
called <code>app.jar</code> in the <code>${dist}/lib</code> directory.</p>
<pre> <jar destfile="${dist}/lib/app.jar"
<h4>With filters</h4>
<blockquote><pre> <jar destfile="${dist}/lib/app.jar"
basedir="${build}/classes"
basedir="${build}/classes"
excludes="**/Test.class"
excludes="**/Test.class"
/></pre>
/></pre></blockquote>
<p>jars all files in the <code>${build}/classes</code> directory into a file
<p>jars all files in the <code>${build}/classes</code> directory into a file
called <code>app.jar</code> in the <code>${dist}/lib</code> directory. Files
called <code>app.jar</code> in the <code>${dist}/lib</code> directory. Files
with the name <code>Test.class</code> are excluded.</p>
with the name <code>Test.class</code> are excluded.</p>
<pre> <jar destfile="${dist}/lib/app.jar"
<blockquote> <pre> <jar destfile="${dist}/lib/app.jar"
basedir="${build}/classes"
basedir="${build}/classes"
includes="mypackage/test/**"
includes="mypackage/test/**"
excludes="**/Test.class"
excludes="**/Test.class"
/></pre>
/></pre></blockquote>
<p>jars all files in the <code>${build}/classes</code> directory into a file
<p>jars all files in the <code>${build}/classes</code> directory into a file
called <code>app.jar</code> in the <code>${dist}/lib</code> directory. Only
called <code>app.jar</code> in the <code>${dist}/lib</code> directory. Only
files under the directory <code>mypackage/test</code> are used, and files with
files under the directory <code>mypackage/test</code> are used, and files with
the name <code>Test.class</code> are excluded.</p>
the name <code>Test.class</code> are excluded.</p>
<pre> <jar destfile="${dist}/lib/app.jar">
<h4>Multiple filesets</h4>
<blockquote><pre> <jar destfile="${dist}/lib/app.jar">
<fileset dir="${build}/classes"
<fileset dir="${build}/classes"
excludes="**/Test.class"
excludes="**/Test.class"
/>
/>
<fileset dir="${src}/resources"/>
<fileset dir="${src}/resources"/>
</jar></pre>
</jar></pre></blockquote>
<p>jars all files in the <code>${build}/classes</code> directory and also
<p>jars all files in the <code>${build}/classes</code> directory and also
in the <code>${src}/resources</code> directory together into a file
in the <code>${src}/resources</code> directory together into a file
called <code>app.jar</code> in the <code>${dist}/lib</code> directory.
called <code>app.jar</code> in the <code>${dist}/lib</code> directory.
@@ -463,19 +468,25 @@ and <code>${src}/resources/mypackage/image.gif</code>, they will appear
in the same directory in the JAR (and thus be considered in the same package
in the same directory in the JAR (and thus be considered in the same package
by Java).</p>
by Java).</p>
<pre> <jar destfile="build/main/checksites.jar">
<h4>Using zipfileset</h4>
<blockquote><pre> <jar destfile="build/main/checksites.jar">
<fileset dir="build/main/classes"/>
<fileset dir="build/main/classes"/>
<zipfileset src="lib/main/util.jar">
<zipfileset includes="**/*.class">
<fileset dir="lib/main" includes="**/*.jar"/>
</zipfileset>
<manifest>
<manifest>
<attribute name="Main-Class"
<attribute name="Main-Class"
value="com.acme.checksites.Main"/>
value="com.acme.checksites.Main"/>
</manifest>
</manifest>
</jar></pre>
</jar></pre></blockquote>
<p>
<p>
Creates an executable jar file with a main class "com.acme.checksites.Main", and
Creates an executable jar file with a main class "com.acme.checksites.Main", and
embeds all the classes from util.jar .
embeds all the classes from all the jars in <code>lib/main</code> .
</p>
</p>
<pre> <jar destfile="test.jar" basedir=".">
<h4>Inline manifest</h4>
<blockquote><pre> <jar destfile="test.jar" basedir=".">
<include name="build"/>
<include name="build"/>
<manifest>
<manifest>
<!-- Who is building this jar? -->
<!-- Who is building this jar? -->
@@ -489,13 +500,14 @@ by Java).</p>
<attribute name="Sealed" value="false"/>
<attribute name="Sealed" value="false"/>
</section>
</section>
</manifest>
</manifest>
</jar></pre>
</jar></pre></blockquote>
<p>
<p>
This is an example of an inline manifest specification including the version of the build
This is an example of an inline manifest specification including the version of the build
program (Implementation-Version). Note that the Built-By attribute will take the value of the Ant
program (Implementation-Version). 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:
property ${user.name}. The manifest produced by the above would look like this:
</p>
</p>
<pre><code>Manifest-Version: 1.0
<blockquote><pre><code>Manifest-Version: 1.0
Built-By: conor
Built-By: conor
Implementation-Vendor: ACME inc.
Implementation-Vendor: ACME inc.
Implementation-Title: GreatProduct
Implementation-Title: GreatProduct
@@ -503,8 +515,9 @@ Implementation-Version: 1.0.0beta2
Created-By: Apache Ant 1.7.0
Created-By: Apache Ant 1.7.0
Name: common/MyClass.class
Name: common/MyClass.class
Sealed: false</code></pre>
Sealed: false</code></pre></blockquote>
<h4>Service Provider</h4>
<p>
<p>
The following shows how to create a jar file specifing a service
The following shows how to create a jar file specifing a service
@@ -517,6 +530,8 @@ Sealed: false</code></pre>
</jar>
</jar>
</pre></blockquote>
</pre></blockquote>
<p>
<p>
The following shows how to create a jar file specifing a service
The following shows how to create a jar file specifing a service
with two implementations of the JDK6 scripting interface:
with two implementations of the JDK6 scripting interface: