”;
Description
Jar task jars a set of file.
Properties
Sr.No | Attributes & Description |
---|---|
1 |
Destfile
The JAR file to create. |
2 |
Basedir
The directory from which to jar the files. |
3 |
Compress
Not only store data but also compress them. Unless you set the keepcompression attribute to false, this will apply to the entire archive, not only the files you”ve added while updating. |
4 |
Keepcompression
For entries coming from existing archives (like nested zipfilesets or while updating the archive), keep the compression as it has been originally instead of using the compress attribute. |
5 |
Encoding
The character encoding to use for filenames inside the archive. |
6 |
Filesonly
Store only file entries. |
7 |
Include
comma- or space-separated list of patterns of files that must be included. |
8 |
Includesfile
Name of a file. Each line of this file is taken to be an include pattern. |
9 |
Excludes
comma- or space-separated list of patterns of files that must be excluded. |
10 |
Excludesfile
Name of a file. Each line of this file is taken to be an exclude pattern. |
11 |
Defaultexcludes
Indicates whether default excludes should be used or not (yes|no). |
12 |
Menifest
The manifest file to use. |
13 |
Filesetmanifest
Behavior when a manifest file is found in a zipfileset or zipgroupfileset file. Valid values are skip, merge, and mergewithoutmain. merge will merge all of the manifests together, and merge this into any other specified manifests. mergewithoutmain merges everything but the Main section of the manifests. |
14 |
Whenmanifestonly
Behavior when no files match. Valid values are fail, skip, and create. |
15 |
Manifestencoding
The encoding used to read the JAR manifest, when a manifest file is specified. |
16 |
Index
Whether to create an index list to speed up classloading. Unless you specify additional jars with nested indexjars elements, only the contents of this jar will be included in the index. |
17 |
indexMetaInf
Whether to include META-INF and its children in the index. Doesn”t have any effect if index is false. Oracle”s jar implementation used to skip the META-INF directory and Ant followed that example. The behavior has been changed with Java 5. In order to avoid problems with Ant generated jars on Java 1.4 or earlier, Ant will not include META-INF unless explicitly asked to. |
18 |
Manifestencoding
The encoding used to read the JAR manifest, when a manifest file is specified. |
19 |
Update
Indicates whether to update or overwrite the destination file if it already exists. |
20 |
Duplicate
Behavior when a duplicate file is found. Valid values are add, preserve, and fail. |
21 |
Roundup
Whether the file modification times will be rounded up to the next even number of seconds. |
22 |
Level
Non-default level at which file compression should be performed. Valid values range from 0 (no compression/fastest) to 9 (maximum compression/slowest). |
23 |
preserve0permissions
When updating an archive or adding entries from a different archive Ant will assume that a Unix permissions value of 0 (nobody is allowed to do anything to the file/directory) means that the permissions haven”t been stored at all rather than real permissions and will instead apply its own default values. |
24 |
useLanguageEncodingFlag
Whether to set the language encoding flag if the encoding is UTF-8. This setting doesn”t have any effect if the encoding is not UTF-8. |
25 |
createUnicodeExtraFields
Whether to create Unicode extra fields to store the file names a second time inside the entry”s metadata. |
26 |
fallbacktoUTF8
Whether to use UTF-8 and the language encoding flag instead of the specified encoding if a file name cannot be encoded using the specified encoding. |
27 |
mergeClassPathAttributes
Whether to merge the Class-Path attributes found in different manifests (if merging manifests). If false, only the attribute of the last merged manifest will be preserved. |
28 |
flattenAttributes
Whether to merge attributes occurring more than once in a section (this can only happen for the Class-Path attribute) into a single attribute. |
29 |
zip64Mode
When to use Zip64 extensions for entries. The possible values are never, always and as-needed. |
Example
Usage
Create build.xml with the following content −
<?xml version="1.0"?> <project name="TutorialPoint" default="info"> <target name="info"> <jar basedir="app" destfile="app.jar" /> <echo>jar created.</echo> </target> </project>
Above script will create an ear file in the current directory as myapp.ear.
Output
Running Ant on the above build file produces the following output −
F:tutorialspointant>ant Buildfile: F:tutorialspointantbuild.xml info: [jar] Building jar: F:tutorialspointantapp.jar [echo] jar created. BUILD SUCCESSFUL Total time: 0 seconds
”;