Create jar file ant


















Create an executable jar file with a main class com. 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 property user.

The manifest produced by the above would look like this:. The following shows how to create a jar file specifying a service with an implementation of the scripting interface:. The following shows how to create a jar file specifying a service with two implementations of the scripting interface:. It defines on top of a JAR the possibility to place additional or overwriting classes in a jar, which are available according to the Java version you run.

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. For entries coming from existing archives like nested zipfileset s or while updating the archive , keep the compression as it has been originally instead of using the compress attribute. Since Ant 1. The character encoding to use for filenames inside the archive. It is not recommended to change this value as the created archive will most likely be unreadable for Java otherwise.

See also the discussion in the zip task page. This can be either the location of a manifest, or the name of a jar added through a fileset. Valid values are skip , merge , and mergewithoutmain. Valid values are fail , skip , and create. Valid values are add , preserve , and fail. Unless you specify additional jars with nested indexjars elements, only the contents of this jar will be included in the index.

Doesn't have any effect if index is false. The behavior has been changed with Java 5. In order to avoid problems with Ant generated jars on Java 1. The encoding used to read the JAR manifest, when a manifest file is specified. The task will always use UTF-8 when writing the manifest. Whether the file modification times will be rounded up to the next even number of seconds. Zip archives store file modification times with a granularity of 2 seconds, so the times will either be rounded up or down.

If you round down, the archive will always seem out-of-date when you rerun the task, so the default is to round up. Rounding up may lead to a different type of problems like JSPs inside a web archive that seem to be slightly more recent than precompiled pages, rendering precompilation useless. Non-default level at which file compression should be performed. As you saw in the above build file we have added a new target to produce the jar file. But before that, let us see the jar task given below.

If we want to make the HelloWorld. Dinesh Rajput is the chief editor of a website Dineshonjava, a technical blog dedicated to the Spring and Java technologies. It has a series of articles related to Java technologies. 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. However, we are excluding the classes that end with the name Test.



0コメント

  • 1000 / 1000