FileDocCategorySizeDatePackage
Ear.javaAPI DocApache Ant 1.705013Wed Dec 13 06:16:20 GMT 2006org.apache.tools.ant.taskdefs

Ear

public class Ear extends Jar
Creates a EAR archive. Based on WAR task
since
Ant 1.4
ant.task
category="packaging"

Fields Summary
private static final org.apache.tools.ant.util.FileUtils
FILE_UTILS
private File
deploymentDescriptor
private boolean
descriptorAdded
Constructors Summary
public Ear()
Create an Ear task.


             
      
        super();
        archiveType = "ear";
        emptyBehavior = "create";
    
Methods Summary
public voidaddArchives(org.apache.tools.ant.types.ZipFileSet fs)
Adds zipfileset.

param
fs zipfileset to add

        // We just set the prefix for this fileset, and pass it up.
        // Do we need to do this? LH
        fs.setPrefix("/");
        super.addFileset(fs);
    
protected voidcleanUp()
Make sure we don't think we already have a application.xml next time this task gets executed.

        descriptorAdded = false;
        super.cleanUp();
    
protected voidinitZipOutputStream(org.apache.tools.zip.ZipOutputStream zOut)
Initialize the output stream.

param
zOut the zip output stream.
throws
IOException on I/O errors
throws
BuildException on other errors

        // If no webxml file is specified, it's an error.
        if (deploymentDescriptor == null && !isInUpdateMode()) {
            throw new BuildException("appxml attribute is required", getLocation());
        }

        super.initZipOutputStream(zOut);
    
public voidsetAppxml(java.io.File descr)
File to incorporate as application.xml.

param
descr the descriptor file

        deploymentDescriptor = descr;
        if (!deploymentDescriptor.exists()) {
            throw new BuildException("Deployment descriptor: "
                                     + deploymentDescriptor
                                     + " does not exist.");
        }

        // Create a ZipFileSet for this file, and pass it up.
        ZipFileSet fs = new ZipFileSet();
        fs.setFile(deploymentDescriptor);
        fs.setFullpath("META-INF/application.xml");
        super.addFileset(fs);
    
public voidsetEarfile(java.io.File earFile)
Set the destination file.

param
earFile the destination file
deprecated
since 1.5.x. Use setDestFile(destfile) instead.

        setDestFile(earFile);
    
protected voidzipFile(java.io.File file, org.apache.tools.zip.ZipOutputStream zOut, java.lang.String vPath, int mode)
Overridden from Zip class to deal with application.xml

param
file the file to add to the archive
param
zOut the stream to write to
param
vPath the name this entry shall have in the archive
param
mode the Unix permissions to set.
throws
IOException on error

        // If the file being added is META-INF/application.xml, we
        // warn if it's not the one specified in the "appxml"
        // attribute - or if it's being added twice, meaning the same
        // file is specified by the "appxml" attribute and in a
        // <fileset> element.
        if (vPath.equalsIgnoreCase("META-INF/application.xml"))  {
            if (deploymentDescriptor == null
                || !FILE_UTILS.fileNameEquals(deploymentDescriptor, file)
                || descriptorAdded) {
                log("Warning: selected " + archiveType
                    + " files include a META-INF/application.xml which will"
                    + " be ignored (please use appxml attribute to "
                    + archiveType + " task)", Project.MSG_WARN);
            } else {
                super.zipFile(file, zOut, vPath, mode);
                descriptorAdded = true;
            }
        } else {
            super.zipFile(file, zOut, vPath, mode);
        }