![]()
|
JarDescriptionJars a set of files. The basedir attribute is the reference directory from where to jar. Note that file permissions will not be stored in the resulting jarfile. It is possible to refine the set of files that are being jarred. This can be done with the includes, includesfile, excludes, excludesfile and defaultexcludes attributes. With the includes or includesfile attribute you specify the files you want to have included by using patterns. The exclude or excludesfile attribute is used to specify the files you want to have excluded. This is also done with patterns. And finally with the defaultexcludes attribute, you can specify whether you want to use default exclusions or not. See the section on directory based tasks, on how the inclusion/exclusion of files works, and how to write patterns. This task forms an implicit FileSet and
supports all attributes of You can also use nested file sets for more flexibility, and specify multiple ones to merge together different trees of files into one JAR. The extended fileset and groupfileset attributes from the zip task are also available in the jar task. See the Zip task for more details and examples. If the manifest is omitted, a simple one will be supplied by Ant. The (The Jar task is a shortcut for specifying the manifest file of a JAR file. The same thing can be accomplished by using the fullpath attribute of a zipfileset in a Zip task. The one difference is that if the manifest attribute is not specified, the Jar task will include an empty one for you.) Manifests are processed by the Jar task according to the Jar file specification. Note in particular that this may result in manifest lines greater than 72 bytes being wrapped and continued on the next line. Parameters
Nested elementsmetainfThe nested manifestThe manifest nested element allows the manifest for the Jar file to be provided inline in the build file rather than in an external file. This element is identical to the manifest task, but its file and mode attributes will be ignored. If both an inline manifest and an external file are both specified, the manifests are merged. When using inline manifests, the Jar task will check whether the build file is more recent that the Jar file when deciding whether to rebuild the Jar. This will not take into account property file changes which may affect the resulting Jar. Examples<jar destfile="${dist}/lib/app.jar" basedir="${build}/classes"/> jars all files in the <jar destfile="${dist}/lib/app.jar" basedir="${build}/classes" excludes="**/Test.class" /> jars all files in the <jar destfile="${dist}/lib/app.jar" basedir="${build}/classes" includes="mypackage/test/**" excludes="**/Test.class" /> jars all files in the <jar destfile="${dist}/lib/app.jar"> <fileset dir="${build}/classes" excludes="**/Test.class" /> <fileset dir="${src}/resources"/> </jar> jars all files in the <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:
Copyright © 2000-2002 Apache Software Foundation. All rights Reserved. |