elements for the implicit fileset. Cosmetics. git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@272371 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -77,6 +77,8 @@ import java.util.Vector; | |||
| * @author Glenn McAllister <a href="mailto:glennm@ca.ibm.com">glennm@ca.ibm.com</a> | |||
| * @author Jon S. Stevens <a href="mailto:jon@latchkey.com">jon@latchkey.com</a> | |||
| * | |||
| * @since 1.2 | |||
| * | |||
| * @ant.task category="filesystem" | |||
| */ | |||
| public class Delete extends MatchingTask { | |||
| @@ -84,7 +86,8 @@ public class Delete extends MatchingTask { | |||
| protected File dir = null; | |||
| protected Vector filesets = new Vector(); | |||
| protected boolean usedMatchingTask = false; | |||
| protected boolean includeEmpty = false; // by default, remove matching empty dirs | |||
| // by default, remove matching empty dirs | |||
| protected boolean includeEmpty = false; | |||
| private int verbosity = Project.MSG_VERBOSE; | |||
| private boolean quiet = false; | |||
| @@ -168,6 +171,14 @@ public class Delete extends MatchingTask { | |||
| return super.createInclude(); | |||
| } | |||
| /** | |||
| * add a name entry on the include files list | |||
| */ | |||
| public PatternSet.NameEntry createIncludesFile() { | |||
| usedMatchingTask = true; | |||
| return super.createIncludesFile(); | |||
| } | |||
| /** | |||
| * add a name entry on the exclude list | |||
| */ | |||
| @@ -176,6 +187,14 @@ public class Delete extends MatchingTask { | |||
| return super.createExclude(); | |||
| } | |||
| /** | |||
| * add a name entry on the include files list | |||
| */ | |||
| public PatternSet.NameEntry createExcludesFile() { | |||
| usedMatchingTask = true; | |||
| return super.createExcludesFile(); | |||
| } | |||
| /** | |||
| * add a set of patterns | |||
| */ | |||
| @@ -245,16 +264,19 @@ public class Delete extends MatchingTask { | |||
| */ | |||
| public void execute() throws BuildException { | |||
| if (usedMatchingTask) { | |||
| log("DEPRECATED - Use of the implicit FileSet is deprecated. Use a nested fileset element instead."); | |||
| log("DEPRECATED - Use of the implicit FileSet is deprecated. " | |||
| + "Use a nested fileset element instead."); | |||
| } | |||
| if (file == null && dir == null && filesets.size() == 0) { | |||
| throw new BuildException("At least one of the file or dir attributes, or a fileset element, must be set."); | |||
| throw new BuildException("At least one of the file or dir " | |||
| + "attributes, or a fileset element, " | |||
| + "must be set."); | |||
| } | |||
| if (quiet && failonerror) { | |||
| throw new BuildException("quiet and failonerror cannot both be set to true", | |||
| location); | |||
| throw new BuildException("quiet and failonerror cannot both be " | |||
| + "set to true", location); | |||
| } | |||
| @@ -262,33 +284,39 @@ public class Delete extends MatchingTask { | |||
| if (file != null) { | |||
| if (file.exists()) { | |||
| if (file.isDirectory()) { | |||
| log("Directory " + file.getAbsolutePath() + " cannot be removed using the file attribute. Use dir instead."); | |||
| log("Directory " + file.getAbsolutePath() | |||
| + " cannot be removed using the file attribute. " | |||
| + "Use dir instead."); | |||
| } else { | |||
| log("Deleting: " + file.getAbsolutePath()); | |||
| if (!file.delete()) { | |||
| String message="Unable to delete file " + file.getAbsolutePath(); | |||
| String message="Unable to delete file " | |||
| + file.getAbsolutePath(); | |||
| if(failonerror) { | |||
| throw new BuildException(message); | |||
| } else { | |||
| log(message, | |||
| quiet ? Project.MSG_VERBOSE : Project.MSG_WARN); | |||
| log(message, quiet ? Project.MSG_VERBOSE | |||
| : Project.MSG_WARN); | |||
| } | |||
| } | |||
| } | |||
| } else { | |||
| log("Could not find file " + file.getAbsolutePath() + " to delete.", | |||
| log("Could not find file " + file.getAbsolutePath() | |||
| + " to delete.", | |||
| Project.MSG_VERBOSE); | |||
| } | |||
| } | |||
| // delete the directory | |||
| if (dir != null && dir.exists() && dir.isDirectory() && !usedMatchingTask) { | |||
| if (dir != null && dir.exists() && dir.isDirectory() && | |||
| !usedMatchingTask) { | |||
| /* | |||
| If verbosity is MSG_VERBOSE, that mean we are doing regular logging | |||
| (backwards as that sounds). In that case, we want to print one | |||
| message about deleting the top of the directory tree. Otherwise, | |||
| the removeDir method will handle messages for _all_ directories. | |||
| If verbosity is MSG_VERBOSE, that mean we are doing | |||
| regular logging (backwards as that sounds). In that | |||
| case, we want to print one message about deleting the | |||
| top of the directory tree. Otherwise, the removeDir | |||
| method will handle messages for _all_ directories. | |||
| */ | |||
| if (verbosity == Project.MSG_VERBOSE) { | |||
| log("Deleting directory " + dir.getAbsolutePath()); | |||
| @@ -341,7 +369,7 @@ public class Delete extends MatchingTask { | |||
| protected void removeDir(File d) { | |||
| String[] list = d.list(); | |||
| if (list == null) { | |||
| list = new String[0]; | |||
| list = new String[0]; | |||
| } | |||
| for (int i = 0; i < list.length; i++) { | |||
| String s = list[i]; | |||
| @@ -351,7 +379,8 @@ public class Delete extends MatchingTask { | |||
| } else { | |||
| log("Deleting " + f.getAbsolutePath(), verbosity); | |||
| if (!f.delete()) { | |||
| String message="Unable to delete file " + f.getAbsolutePath(); | |||
| String message="Unable to delete file " | |||
| + f.getAbsolutePath(); | |||
| if(failonerror) { | |||
| throw new BuildException(message); | |||
| } else { | |||
| @@ -363,7 +392,8 @@ public class Delete extends MatchingTask { | |||
| } | |||
| log("Deleting directory " + d.getAbsolutePath(), verbosity); | |||
| if (!d.delete()) { | |||
| String message="Unable to delete directory " + dir.getAbsolutePath(); | |||
| String message="Unable to delete directory " | |||
| + dir.getAbsolutePath(); | |||
| if(failonerror) { | |||
| throw new BuildException(message); | |||
| } else { | |||
| @@ -382,12 +412,14 @@ public class Delete extends MatchingTask { | |||
| */ | |||
| protected void removeFiles(File d, String[] files, String[] dirs) { | |||
| if (files.length > 0) { | |||
| log("Deleting " + files.length + " files from " + d.getAbsolutePath()); | |||
| log("Deleting " + files.length + " files from " | |||
| + d.getAbsolutePath()); | |||
| for (int j=0; j<files.length; j++) { | |||
| File f = new File(d, files[j]); | |||
| log("Deleting " + f.getAbsolutePath(), verbosity); | |||
| if (!f.delete()) { | |||
| String message="Unable to delete file " + f.getAbsolutePath(); | |||
| String message="Unable to delete file " | |||
| + f.getAbsolutePath(); | |||
| if(failonerror) { | |||
| throw new BuildException(message); | |||
| } else { | |||
| @@ -110,6 +110,7 @@ import org.apache.tools.ant.types.FileList; | |||
| * @author <a href="mailto:cstrong@arielpartners.com">Craeg Strong</a> | |||
| * @ant.task category="filesystem" | |||
| * @version $Revision$ $Date$ | |||
| * @since Ant 1.4 | |||
| */ | |||
| public class DependSet extends MatchingTask { | |||
| @@ -159,11 +160,13 @@ public class DependSet extends MatchingTask { | |||
| public void execute() throws BuildException { | |||
| if ( (sourceFileSets.size() == 0) && (sourceFileLists.size() == 0) ) { | |||
| throw new BuildException("At least one <srcfileset> or <srcfilelist> element must be set"); | |||
| throw new BuildException("At least one <srcfileset> or <srcfilelist>" | |||
| + " element must be set"); | |||
| } | |||
| if ( (targetFileSets.size() == 0) && (targetFileLists.size() == 0) ) { | |||
| throw new BuildException("At least one <targetfileset> or <targetfilelist> element must be set"); | |||
| throw new BuildException("At least one <targetfileset> or" | |||
| + " <targetfilelist> element must be set"); | |||
| } | |||
| long now = (new Date()).getTime(); | |||
| @@ -255,8 +258,8 @@ public class DependSet extends MatchingTask { | |||
| Enumeration enumSourceLists = sourceFileLists.elements(); | |||
| while (upToDate && enumSourceLists.hasMoreElements()) { | |||
| FileList sourceFL = (FileList) enumSourceLists.nextElement(); | |||
| String[] sourceFiles = sourceFL.getFiles(project); | |||
| FileList sourceFL = (FileList) enumSourceLists.nextElement(); | |||
| String[] sourceFiles = sourceFL.getFiles(project); | |||
| for (int i=0; upToDate && i < sourceFiles.length; i++) { | |||
| File src = new File(sourceFL.getDir(project), sourceFiles[i]); | |||
| @@ -267,7 +270,8 @@ public class DependSet extends MatchingTask { | |||
| } | |||
| if (!src.exists()) { | |||
| log(sourceFiles[i]+ " does not exist.", Project.MSG_VERBOSE); | |||
| log(sourceFiles[i]+ " does not exist.", | |||
| Project.MSG_VERBOSE); | |||
| upToDate = false; | |||
| break; | |||
| } | |||
| @@ -288,7 +292,7 @@ public class DependSet extends MatchingTask { | |||
| Enumeration enumSourceSets = sourceFileSets.elements(); | |||
| while (upToDate && enumSourceSets.hasMoreElements()) { | |||
| FileSet sourceFS = (FileSet) enumSourceSets.nextElement(); | |||
| FileSet sourceFS = (FileSet) enumSourceSets.nextElement(); | |||
| DirectoryScanner sourceDS = sourceFS.getDirectoryScanner(project); | |||
| String[] sourceFiles = sourceDS.getIncludedFiles(); | |||
| @@ -313,11 +317,11 @@ public class DependSet extends MatchingTask { | |||
| log("Deleting all target files. ", Project.MSG_VERBOSE); | |||
| for (Enumeration e = allTargets.elements(); e.hasMoreElements(); ) { | |||
| File fileToRemove = (File)e.nextElement(); | |||
| log("Deleting file " + fileToRemove.getAbsolutePath(), Project.MSG_VERBOSE); | |||
| log("Deleting file " + fileToRemove.getAbsolutePath(), | |||
| Project.MSG_VERBOSE); | |||
| fileToRemove.delete(); | |||
| } | |||
| } | |||
| } //-- execute | |||
| @@ -61,13 +61,14 @@ import org.apache.tools.zip.ZipOutputStream; | |||
| import java.io.File; | |||
| import java.io.IOException; | |||
| /** | |||
| * Creates a EAR archive. Based on WAR task | |||
| * | |||
| * @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a> | |||
| * @author <a href="mailto:leslie.hughes@rubus.com">Les Hughes</a> | |||
| * | |||
| * @since Ant 1.4 | |||
| * | |||
| * @ant.task category="packaging" | |||
| */ | |||
| public class Ear extends Jar { | |||
| @@ -94,7 +95,9 @@ public class Ear extends Jar { | |||
| public void setAppxml(File descr) { | |||
| deploymentDescriptor = descr; | |||
| if (!deploymentDescriptor.exists()) { | |||
| throw new BuildException("Deployment descriptor: " + deploymentDescriptor + " does not exist."); | |||
| throw new BuildException("Deployment descriptor: " | |||
| + deploymentDescriptor | |||
| + " does not exist."); | |||
| } | |||
| // Create a ZipFileSet for this file, and pass it up. | |||
| @@ -109,7 +112,6 @@ public class Ear extends Jar { | |||
| public void addArchives(ZipFileSet fs) { | |||
| // We just set the prefix for this fileset, and pass it up. | |||
| // Do we need to do this? LH | |||
| log("addArchives called",Project.MSG_DEBUG); | |||
| fs.setPrefix("/"); | |||
| super.addFileset(fs); | |||
| } | |||
| @@ -129,14 +131,19 @@ public class Ear extends Jar { | |||
| protected void zipFile(File file, ZipOutputStream zOut, String vPath) | |||
| throws IOException | |||
| { | |||
| // 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 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 || !deploymentDescriptor.equals(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); | |||
| if (deploymentDescriptor == null | |||
| || !deploymentDescriptor.equals(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); | |||
| descriptorAdded = true; | |||
| @@ -147,8 +154,8 @@ public class Ear extends Jar { | |||
| } | |||
| /** | |||
| * Make sure we don't think we already have a application.xml next time this task | |||
| * gets executed. | |||
| * Make sure we don't think we already have a application.xml next | |||
| * time this task gets executed. | |||
| */ | |||
| protected void cleanUp() { | |||
| descriptorAdded = false; | |||
| @@ -68,6 +68,8 @@ import java.io.IOException; | |||
| * | |||
| * @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a> | |||
| * | |||
| * @since Ant 1.2 | |||
| * | |||
| * @ant.task category="packaging" | |||
| */ | |||
| public class War extends Jar { | |||
| @@ -94,7 +96,9 @@ public class War extends Jar { | |||
| public void setWebxml(File descr) { | |||
| deploymentDescriptor = descr; | |||
| if (!deploymentDescriptor.exists()) { | |||
| throw new BuildException("Deployment descriptor: " + deploymentDescriptor + " does not exist."); | |||
| throw new BuildException("Deployment descriptor: " | |||
| + deploymentDescriptor | |||
| + " does not exist."); | |||
| } | |||
| // Create a ZipFileSet for this file, and pass it up. | |||
| @@ -137,14 +141,18 @@ public class War extends Jar { | |||
| protected void zipFile(File file, ZipOutputStream zOut, String vPath) | |||
| throws IOException | |||
| { | |||
| // 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 <fileset> element. | |||
| // 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 <fileset> element. | |||
| if (vPath.equalsIgnoreCase("WEB-INF/web.xml")) { | |||
| if (deploymentDescriptor == null || !deploymentDescriptor.equals(file) || descriptorAdded) { | |||
| log("Warning: selected "+archiveType+" files include a WEB-INF/web.xml which will be ignored " + | |||
| "(please use webxml attribute to "+archiveType+" task)", Project.MSG_WARN); | |||
| if (deploymentDescriptor == null | |||
| || !deploymentDescriptor.equals(file) | |||
| || descriptorAdded) { | |||
| log("Warning: selected " + archiveType | |||
| + " files include a WEB-INF/web.xml which will be ignored " | |||
| + "(please use webxml attribute to " | |||
| + archiveType + " task)", Project.MSG_WARN); | |||
| } else { | |||
| super.zipFile(file, zOut, vPath); | |||
| descriptorAdded = true; | |||