Viewed 6k times. How can I do this in ant? Improve this question. Judd Judd 2 2 silver badges 6 6 bronze badges. Add a comment. Active Oldest Votes. Try something like this. Improve this answer. Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password. The base directory for the output JAR file. By default, this is set to the base directory of the project. While the compress attribute is applicable to the individual files, the keepcompression attribute does the same thing, but it applies to the entire archive.
Advises Ant on what to do when duplicate files are found. You could add, preserve, or fail the duplicate files. Continuing our Hello World Fax Application project, let us add a new target to produce the jar files. Here, the web. In our case, this is where the util. The build. In this example, we create a jar file called util. And finally with the defaultexcludes attribute, you can specify whether you want to use default exclusions or not.
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 child elements from the zip task are also available in the jar task.
See the Zip task for more details and examples. The update parameter controls what happens if the JAR file already exists. When set to yes , the JAR file is updated with the files specified. When set to no the default the JAR file is overwritten. An example use of this is provided in the Zip task documentation. Please note that ZIP files store file modification times with a granularity of two seconds. If a file is less than two seconds newer than the entry in the archive, Ant will not consider it newer.
The whenmanifestonly parameter controls what happens when no files, apart from the manifest file, or nested services, match. If skip , the JAR is not created and a warning is issued. If fail , the JAR is not created and the build is halted with an error. If create , default an empty JAR file only containing a manifest and services is created.
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.
The Jar task checks whether you specified package information according to the versioning specification. Please note that the zip format allows multiple files of the same fully-qualified name to exist within a single archive. This has been documented as causing various problems for unsuspecting users. If you wish to avoid this behavior you must set the duplicate attribute to a value other than its default, "add".
The nested metainf element specifies a FileSet. MF , the file is ignored and you will get a warning. The 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 the file and mode attributes must be omitted. When using inline manifests, the Jar task will check whether the manifest contents have changed i. If the manifest values have changed the jar will be updated or rebuilt, as appropriate. The nested indexjars element specifies a PATH like structure. Its content is completely ignored unless you set the index attribute of the task to true.
0コメント