From 95caa3160ed33ae5e3ce6b872ab4b973e5488d6e Mon Sep 17 00:00:00 2001
From: antelder WEB-INF/lib
, WEB-INF/classes
or
- * WEB-INF
directories of the Web Application Archive.
(The War task is a shortcut for specifying the particular layout of a WAR file. - * 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 War task.
- * - * @see JarArchiver - */ -public class ZipArchiver - extends JarArchiver -{ - - /** - * our web.xml deployment descriptor - */ - private File deploymentDescriptor; - - /** - * flag set if finding the webxml is to be expected. - */ - private boolean ignoreWebxml = true; - - /** - * flag set if the descriptor is added - */ - private boolean descriptorAdded; - - public void setIgnoreWebxml( boolean ignore ) { - ignoreWebxml = ignore; - } - - public ZipArchiver() - { - super(); - archiveType = "scazip"; - } - - /** - * set the deployment descriptor to use (WEB-INF/web.xml); - * required unless update=true - */ - public void setWebxml( File descr ) - throws ArchiverException - { - deploymentDescriptor = descr; - if ( !deploymentDescriptor.exists() ) - { - throw new ArchiverException( "Deployment descriptor: " - + deploymentDescriptor - + " does not exist." ); - } - - addFile( descr, "WEB-INF/web.xml" ); - } - - /** - * add a file under WEB-INF/lib/ - */ - - public void addLib( File fileName ) - throws ArchiverException - { - addDirectory( fileName.getParentFile(), "WEB-INF/lib/", new String[]{fileName.getName()}, null ); - } - - /** - * add files under WEB-INF/lib/ - */ - - public void addLibs( File directoryName, String[] includes, String[] excludes ) - throws ArchiverException - { - addDirectory( directoryName, "WEB-INF/lib/", includes, excludes ); - } - - /** - * add a file under WEB-INF/lib/ - */ - - public void addClass( File fileName ) - throws ArchiverException - { - addDirectory( fileName.getParentFile(), "WEB-INF/classes/", new String[]{fileName.getName()}, null ); - } - - /** - * add files under WEB-INF/classes - */ - public void addClasses( File directoryName, String[] includes, String[] excludes ) - throws ArchiverException - { - addDirectory( directoryName, "WEB-INF/classes/", includes, excludes ); - } - - /** - * files to add under WEB-INF; - */ - public void addWebinf( File directoryName, String[] includes, String[] excludes ) - throws ArchiverException - { - addDirectory( directoryName, "WEB-INF/", includes, excludes ); - } - - /** - * override of parent; validates configuration - * before initializing the output stream. - */ - protected void initZipOutputStream( ZipOutputStream zOut ) - throws IOException, ArchiverException - { - super.initZipOutputStream( zOut ); - } - - /** - * Overridden from ZipArchiver class to deal with web.xml - */ - protected void zipFile( ArchiveEntry entry, ZipOutputStream zOut, String vPath, int mode ) - throws IOException, ArchiverException - { - // If the file being added is WEB-INF/web.xml, we warn if it's - // not the one specified in the "webxml" attribute - or if - // it's being added twice, meaning the same file is specified - // by the "webxml" attribute and in a