Ear command is to create the Enterprise Application archive from the ANT scripts. It is an extension to jar task. ( The same thing can be accomplished by using the prefix and fullpath attributes of zipfilesets in a Zip or Jar task.)
The extended zipfileset element from the zip task (with attributes prefix , fullpath , and src ) is available in the Ear task.
The following table will demonstrate the attriutes for the EAR task.
Attribute | Description | Required |
destfile | the EAR file to create. | Yes |
appxml | The deployment descriptor to use (META-INF/application.xml). | Yes, unless update is set to true |
basedir | the directory from which to jar the files. | No |
compress | Not only store data but also compress them, defaults to true. Unless you set the keepcompression attribute to false, this will apply to the entire archive, not only the files you've added while updating. | No |
keepcompression | 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. Defaults false. Since Ant 1.6 | No |
encoding | The character encoding to use for filenames inside the archive. Defaults to UTF8. It is not recommended to change this value as the created archive will most likely be unreadable for Java otherwise. | No |
filesonly | Store only file entries, defaults to false | No |
includes | comma- or space-separated list of patterns of files that must be included. All files are included when omitted. | No |
includesfile | the name of a file. Each line of this file is taken to be an include pattern | No |
excludes | comma- or space-separated list of patterns of files that must be excluded. No files (except default excludes) are excluded when omitted. | No |
excludesfile | the name of a file. Each line of this file is taken to be an exclude pattern | No |
defaultexcludes | indicates whether default excludes should be used or not ("yes"/"no"). Default excludes are used when omitted. | No |
manifest | the manifest file to use. | No |
update | indicates whether to update or overwrite the destination file if it already exists. Default is "false". | No |
duplicate | behavior when a duplicate file is found. Valid values are "add", "preserve", and "fail". The default value is "add". | No |
roundup | 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 two 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. Defaults to true. Since Ant 1.6.2 | No |
level | Non-default level at which file compression should be performed. Valid values range from 0 (no compression/fastest) to 9 (maximum compression/slowest). Since Ant 1.7 | No |
Example
Note:- The following command will include all the jar and war files into the project.ear file.
<ear destfile="build/project.ear" appxml="src/metadata/application.xml">
<fileset dir="build" includes="*.jar,*.war"/>
</ear>
Java Discussion
- - Java web application
- - Difference between BMT an
- - Replace getParameterValue
- - Interviewing Next week -
- - Sudoku solver





