cvs commit: ant/src/main/org/apache/tools/ant/taskdefs Copy.java
mbenson 2005/05/31 12:01:34 Modified:src/main/org/apache/tools/ant/taskdefs Copy.java Log: reorder imports before adding more. Revision ChangesPath 1.84 +8 -8 ant/src/main/org/apache/tools/ant/taskdefs/Copy.java Index: Copy.java === RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/Copy.java,v retrieving revision 1.83 retrieving revision 1.84 diff -u -r1.83 -r1.84 --- Copy.java 9 Mar 2005 00:20:40 - 1.83 +++ Copy.java 31 May 2005 19:01:34 - 1.84 @@ -19,23 +19,23 @@ import java.io.File; import java.io.IOException; -import java.util.Enumeration; -import java.util.Hashtable; import java.util.Vector; +import java.util.Hashtable; +import java.util.Enumeration; +import org.apache.tools.ant.Task; +import org.apache.tools.ant.Project; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.DirectoryScanner; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.Task; +import org.apache.tools.ant.types.Mapper; import org.apache.tools.ant.types.FileSet; -import org.apache.tools.ant.types.FilterChain; import org.apache.tools.ant.types.FilterSet; +import org.apache.tools.ant.types.FilterChain; import org.apache.tools.ant.types.FilterSetCollection; -import org.apache.tools.ant.types.Mapper; -import org.apache.tools.ant.util.FileNameMapper; import org.apache.tools.ant.util.FileUtils; -import org.apache.tools.ant.util.FlatFileNameMapper; +import org.apache.tools.ant.util.FileNameMapper; import org.apache.tools.ant.util.IdentityMapper; import org.apache.tools.ant.util.SourceFileScanner; +import org.apache.tools.ant.util.FlatFileNameMapper; /** * Copies a file or directory to a new file - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: ant/src/main/org/apache/tools/ant/taskdefs Copy.java
mbenson 2005/02/11 10:22:51 Modified:src/main/org/apache/tools/ant/taskdefs Copy.java Log: Javadoc Revision ChangesPath 1.80 +63 -57ant/src/main/org/apache/tools/ant/taskdefs/Copy.java Index: Copy.java === RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/Copy.java,v retrieving revision 1.79 retrieving revision 1.80 diff -u -r1.79 -r1.80 --- Copy.java 4 Jan 2005 20:20:52 - 1.79 +++ Copy.java 11 Feb 2005 18:22:50 - 1.80 @@ -89,39 +89,40 @@ } /** - * @return the fileutils object + * Get the FileUtils for this task. + * @return the fileutils object. */ protected FileUtils getFileUtils() { return fileUtils; } /** - * Sets a single source file to copy. - * @param file the file to copy + * Set a single source file to copy. + * @param file the file to copy. */ public void setFile(File file) { this.file = file; } /** - * Sets the destination file. - * @param destFile the file to copy to + * Set the destination file. + * @param destFile the file to copy to. */ public void setTofile(File destFile) { this.destFile = destFile; } /** - * Sets the destination directory. - * @param destDir the destination directory + * Set the destination directory. + * @param destDir the destination directory. */ public void setTodir(File destDir) { this.destDir = destDir; } /** - * Adds a FilterChain. - * @return a filter chain object + * Add a FilterChain. + * @return a filter chain object. */ public FilterChain createFilterChain() { FilterChain filterChain = new FilterChain(); @@ -130,8 +131,8 @@ } /** - * Adds a filterset. - * @return a filter set object + * Add a filterset. + * @return a filter set object. */ public FilterSet createFilterSet() { FilterSet filterSet = new FilterSet(); @@ -141,7 +142,7 @@ /** * Give the copied files the same last modified time as the original files. - * @param preserve a boolean string + * @param preserve a boolean string. * @deprecated setPreserveLastModified(String) has been deprecated and * replaced with setPreserveLastModified(boolean) to * consistently let the Introspection mechanism work. @@ -152,16 +153,17 @@ /** * Give the copied files the same last modified time as the original files. - * @param preserve if true perverse the modified time, default is false + * @param preserve if true preserve the modified time; default is false. */ public void setPreserveLastModified(boolean preserve) { preserveLastModified = preserve; } /** - * Whether to give the copied files the same last modified time as + * Get whether to give the copied files the same last modified time as * the original files. - * @return the preserveLastModified attribute + * @return the whether destination files will inherit the modification + * times of the corresponding source files. * @since 1.32, Ant 1.5 */ public boolean getPreserveLastModified() { @@ -171,7 +173,7 @@ /** * Get the filtersets being applied to this operation. * - * @return a vector of FilterSet objects + * @return a vector of FilterSet objects. */ protected Vector getFilterSets() { return filterSets; @@ -180,22 +182,22 @@ /** * Get the filterchains being applied to this operation. * - * @return a vector of FilterChain objects + * @return a vector of FilterChain objects. */ protected Vector getFilterChains() { return filterChains; } /** - * If true, enables filtering. - * @param filtering if true enable filtering, default is false + * Set filtering mode. + * @param filtering if true enable filtering; default is false. */ public void setFiltering(boolean filtering) { this.filtering = filtering; } /** - * Overwrite any existing destination file(s). + * Set overwrite mode regarding existing destination file(s). * @param overwrite if true force overwriting of destination file(s) * even if the destination file(s) are younger than * the corresponding source file. Default is false. @@ -205,7 +207,7 @@ } /** - * When copying directory trees, the files can be flattened + * Set whether files
cvs commit: ant/src/main/org/apache/tools/ant/taskdefs Copy.java
mbenson 2005/02/11 10:38:40 Modified:src/main/org/apache/tools/ant/taskdefs Copy.java Log: Removing some (IMO) unnecessary blank lines; a couple of string cat merges; replaced an if block with ?: notation. Revision ChangesPath 1.81 +12 -35ant/src/main/org/apache/tools/ant/taskdefs/Copy.java Index: Copy.java === RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/Copy.java,v retrieving revision 1.80 retrieving revision 1.81 diff -u -r1.80 -r1.81 --- Copy.java 11 Feb 2005 18:22:50 - 1.80 +++ Copy.java 11 Feb 2005 18:38:40 - 1.81 @@ -225,11 +225,7 @@ *Default is false. */ public void setVerbose(boolean verbose) { -if (verbose) { -this.verbosity = Project.MSG_INFO; -} else { -this.verbosity = Project.MSG_VERBOSE; -} +this.verbosity = verbose ? Project.MSG_INFO : Project.MSG_VERBOSE; } /** @@ -371,19 +367,16 @@ // will be removed in validateAttributes savedFileSet = (FileSet) filesets.elementAt(0); } - // make sure we don't have an illegal set of options validateAttributes(); try { - // deal with the single file if (file != null) { if (file.exists()) { if (destFile == null) { destFile = new File(destDir, file.getName()); } - if (forceOverwrite || !destFile.exists() || (file.lastModified() - granularity destFile.lastModified())) { @@ -403,7 +396,6 @@ } } } - // deal with the filesets for (int i = 0; i filesets.size(); i++) { FileSet fs = (FileSet) filesets.elementAt(i); @@ -419,7 +411,6 @@ continue; } } - File fromDir = fs.getDir(getProject()); String[] srcFiles = ds.getIncludedFiles(); @@ -432,7 +423,6 @@ } scan(fromDir, destDir, srcFiles, srcDirs); } - // do all the copy operations now... try { doFileOperations(); @@ -452,7 +442,6 @@ if (savedFileSet != null) { filesets.insertElementAt(savedFileSet, 0); } - fileCopyMap.clear(); dirCopyMap.clear(); completeDirMap.clear(); @@ -471,27 +460,23 @@ */ protected void validateAttributes() throws BuildException { if (file == null filesets.size() == 0) { -throw new BuildException(Specify at least one source - + - a file or a fileset.); +throw new BuildException( +Specify at least one source--a file or a fileset.); } - if (destFile != null destDir != null) { -throw new BuildException(Only one of tofile and todir - + may be set.); +throw new BuildException( +Only one of tofile and todir may be set.); } - if (destFile == null destDir == null) { throw new BuildException(One of tofile or todir must be set.); } - if (file != null file.isDirectory()) { throw new BuildException(Use a fileset to copy directories.); } - if (destFile != null filesets.size() 0) { if (filesets.size() 1) { throw new BuildException( - Cannot concatenate multiple files into a single file.); +Cannot concatenate multiple files into a single file.); } else { FileSet fs = (FileSet) filesets.elementAt(0); DirectoryScanner ds = fs.getDirectoryScanner(getProject()); @@ -499,26 +484,24 @@ if (srcFiles.length == 0) { throw new BuildException( - Cannot perform operation from directory to file.); +Cannot perform operation from directory to file.); } else if (srcFiles.length == 1) { if (file == null) { file = new File(ds.getBasedir(), srcFiles[0]); filesets.removeElementAt(0); } else { -throw new BuildException(Cannot concatenate multiple - +
cvs commit: ant/src/main/org/apache/tools/ant/taskdefs Copy.java
mbenson 2005/02/11 10:48:24 Modified:src/main/org/apache/tools/ant/taskdefs Copy.java Log: File inclusion: unnecessarily checked presence of selectors AND DirectoryScanner.isEverythingIncluded, which will be false if selectors cause omissions. Revision ChangesPath 1.82 +3 -5 ant/src/main/org/apache/tools/ant/taskdefs/Copy.java Index: Copy.java === RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/Copy.java,v retrieving revision 1.81 retrieving revision 1.82 diff -u -r1.81 -r1.82 --- Copy.java 11 Feb 2005 18:38:40 - 1.81 +++ Copy.java 11 Feb 2005 18:48:24 - 1.82 @@ -415,10 +415,8 @@ String[] srcFiles = ds.getIncludedFiles(); String[] srcDirs = ds.getIncludedDirectories(); -boolean isEverythingIncluded = ds.isEverythingIncluded() - (!fs.hasSelectors() !fs.hasPatterns()); -if (isEverythingIncluded - !flatten mapperElement == null) { +if (!flatten mapperElement == null + ds.isEverythingIncluded() !fs.hasPatterns()) { completeDirMap.put(fromDir, destDir); } scan(fromDir, destDir, srcFiles, srcDirs); - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: ant/src/main/org/apache/tools/ant/taskdefs Copy.java DependSet.java
jkf 2005/01/04 12:20:52 Modified:src/main/org/apache/tools/ant/util FileUtils.java src/main/org/apache/tools/ant/types/selectors MappingSelector.java DateSelector.java src/main/org/apache/tools/ant/taskdefs Copy.java DependSet.java Log: Made more consequent use of the method available in FileUtils to get the granularity. Revision ChangesPath 1.80 +16 -4 ant/src/main/org/apache/tools/ant/util/FileUtils.java Index: FileUtils.java === RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/util/FileUtils.java,v retrieving revision 1.79 retrieving revision 1.80 diff -u -r1.79 -r1.80 --- FileUtils.java15 Dec 2004 12:10:43 - 1.79 +++ FileUtils.java4 Jan 2005 20:20:49 - 1.80 @@ -1,5 +1,5 @@ /* - * Copyright 2001-2004 The Apache Software Foundation + * Copyright 2001-2005 The Apache Software Foundation * * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. @@ -58,11 +58,14 @@ */ public class FileUtils { + +private static final FileUtils PRIMARY_INSTANCE = new FileUtils(); + //get some non-crypto-grade randomness from various places. private static Random rand = new Random(System.currentTimeMillis() + Runtime.getRuntime().freeMemory()); -private boolean onNetWare = Os.isFamily(netware); +private static boolean onNetWare = Os.isFamily(netware); // for toURI private static boolean[] isSpecial = new boolean[256]; @@ -106,12 +109,22 @@ * Factory method. * * @return a new instance of FileUtils. + * @deprecated Use getFileUtils instead, FileUtils do not have state. */ public static FileUtils newFileUtils() { return new FileUtils(); } /** + * Method to retrieve The FileUtils, which is shared by all users of this + * method. + * @return an instance of FileUtils. + */ +public static FileUtils getFileUtils() { +return PRIMARY_INSTANCE; +} + +/** * Empty constructor. */ protected FileUtils() { @@ -1355,7 +1368,6 @@ public boolean isUpToDate(long sourceTime, long destTime) { return isUpToDate(sourceTime, destTime, getFileTimestampGranularity()); } - /** * close a writer without throwing any exception if something went wrong. 1.14 +4 -4 ant/src/main/org/apache/tools/ant/types/selectors/MappingSelector.java Index: MappingSelector.java === RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/types/selectors/MappingSelector.java,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- MappingSelector.java 9 Mar 2004 16:48:47 - 1.13 +++ MappingSelector.java 4 Jan 2005 20:20:52 - 1.14 @@ -1,5 +1,5 @@ /* - * Copyright 2000-2004 The Apache Software Foundation + * Copyright 2000-2005 The Apache Software Foundation * * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. @@ -40,7 +40,7 @@ * */ public MappingSelector() { -granularity = (int) FileUtils.newFileUtils().getFileTimestampGranularity(); +granularity = (int) FileUtils.getFileUtils().getFileTimestampGranularity(); } @@ -128,8 +128,8 @@ /** * Sets the number of milliseconds leeway we will give before we consider - * a file out of date. Defaults to 2000 on MS-DOS derivatives as the FAT - * file system. + * a file out of date. Defaults to 2000 on MS-DOS derivatives and 1000 on + * others. * @param granularity the leeway in milliseconds */ public void setGranularity(int granularity) { 1.17 +4 -5 ant/src/main/org/apache/tools/ant/types/selectors/DateSelector.java Index: DateSelector.java === RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/types/selectors/DateSelector.java,v retrieving revision 1.16 retrieving revision 1.17 diff -u -r1.16 -r1.17 --- DateSelector.java 16 Dec 2004 15:02:48 - 1.16 +++ DateSelector.java 4 Jan 2005 20:20:52 - 1.17 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2004 The Apache Software Foundation + * Copyright 2002-2005 The Apache Software Foundation * * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. @@ -27,6 +27,7 @@ import
Re: cvs commit: ant/src/main/org/apache/tools/ant/taskdefs Copy.java DependSet.java
Hi Unless anyone objects within the next few days I will apply a patch that will make use of getFileUtils instead of newFileUtils in all files in a uniform way (122 files impacted). I have manually checked if it could do any harm when using the same instance of the FileUtils everywhere and could not find a single spot where it could do harm. The Copy task leaks the fileutils instance it created to derived classes, so there might be subclasses of Copy that assume for some reason that Copy would create a new fileutils for every instance. I chose to ignore the fact that such misuse might be made by subclasses of Copy. I did take into account that the derived class of Copy might have provided an own/other implementation of FileUtils. (Though I would have liked to ignore this). Kind Regards, Martijn [EMAIL PROTECTED] wrote: jkf 2005/01/04 12:20:52 Modified:src/main/org/apache/tools/ant/util FileUtils.java src/main/org/apache/tools/ant/types/selectors MappingSelector.java DateSelector.java src/main/org/apache/tools/ant/taskdefs Copy.java DependSet.java Log: Made more consequent use of the method available in FileUtils to get the granularity. Revision ChangesPath 1.80 +16 -4 ant/src/main/org/apache/tools/ant/util/FileUtils.java Index: FileUtils.java === RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/util/FileUtils.java,v retrieving revision 1.79 retrieving revision 1.80 diff -u -r1.79 -r1.80 --- FileUtils.java 15 Dec 2004 12:10:43 - 1.79 +++ FileUtils.java 4 Jan 2005 20:20:49 - 1.80 * * @return a new instance of FileUtils. + * @deprecated Use getFileUtils instead, FileUtils do not have state. */ public static FileUtils newFileUtils() { return new FileUtils(); } /** + * Method to retrieve The FileUtils, which is shared by all users of this + * method. + * @return an instance of FileUtils. + */ +public static FileUtils getFileUtils() { +return PRIMARY_INSTANCE; +} + - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: ant/src/main/org/apache/tools/ant/taskdefs Copy.java
peterreilly2004/12/10 05:21:54 Modified:docs/manual/CoreTasks Tag: ANT_16_BRANCH copy.html src/main/org/apache/tools/ant/taskdefs Tag: ANT_16_BRANCH Copy.java Log: sync: copy's filenamemapper type support Revision ChangesPath No revision No revision 1.19.2.10 +5 -3 ant/docs/manual/CoreTasks/copy.html Index: copy.html === RCS file: /home/cvs/ant/docs/manual/CoreTasks/copy.html,v retrieving revision 1.19.2.9 retrieving revision 1.19.2.10 diff -u -r1.19.2.9 -r1.19.2.10 --- copy.html 7 Dec 2004 23:43:22 - 1.19.2.9 +++ copy.html 10 Dec 2004 13:21:50 - 1.19.2.10 @@ -152,6 +152,10 @@ href=../CoreTypes/mapper.htmlmapper/a element. The default mapper used by codelt;copygt;/code is the a href=../CoreTypes/mapper.html#identity-mapperidentity mapper/a./p + p +emSince Ant 1.6.3/em, +one can use a filenamemapper type in place of the mapper element. + /p h4filterset/h4 pa href=../CoreTypes/filterset.htmlFilterSet/as are used to replace @@ -200,9 +204,7 @@ pre lt;copy todir=quot;../backup/dirquot;gt; lt;fileset dir=quot;src_dirquot;/gt; -lt;mappergt; -lt;globmapper from=quot;*quot; to=quot;*.bakquot;/gt; -lt;/mappergt; +lt;globmapper from=quot;*quot; to=quot;*.bakquot;/gt; lt;/copygt; /pre No revision No revision 1.66.2.7 +11 -1 ant/src/main/org/apache/tools/ant/taskdefs/Copy.java Index: Copy.java === RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/Copy.java,v retrieving revision 1.66.2.6 retrieving revision 1.66.2.7 diff -u -r1.66.2.6 -r1.66.2.7 --- Copy.java 1 Sep 2004 07:02:23 - 1.66.2.6 +++ Copy.java 10 Dec 2004 13:21:51 - 1.66.2.7 @@ -290,6 +290,16 @@ } /** + * A nested filenamemapper + * @param fileNameMapper the mapper to add + * @since Ant 1.6.3 + */ +public void add(FileNameMapper fileNameMapper) { +createMapper().add(fileNameMapper); +} + + +/** * Sets the character encoding * @param encoding the character encoding * @since 1.32, Ant 1.5 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: ant/src/main/org/apache/tools/ant/taskdefs Copy.java
mbenson 2004/09/20 13:16:22 Modified:src/main/org/apache/tools/ant/taskdefs Copy.java Log: Remove unnecessary exists() check. Revision ChangesPath 1.74 +2 -2 ant/src/main/org/apache/tools/ant/taskdefs/Copy.java Index: Copy.java === RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/Copy.java,v retrieving revision 1.73 retrieving revision 1.74 diff -u -r1.73 -r1.74 --- Copy.java 1 Sep 2004 05:38:54 - 1.73 +++ Copy.java 20 Sep 2004 20:16:22 - 1.74 @@ -467,7 +467,7 @@ throw new BuildException(One of tofile or todir must be set.); } -if (file != null file.exists() file.isDirectory()) { +if (file != null file.isDirectory()) { throw new BuildException(Use a fileset to copy directories.); } - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: ant/src/main/org/apache/tools/ant/taskdefs Copy.java
jhm 2004/09/01 00:02:23 Modified:src/main/org/apache/tools/ant/taskdefs Tag: ANT_16_BRANCH Copy.java Log: Let move compile. Revision ChangesPath No revision No revision 1.66.2.6 +2 -2 ant/src/main/org/apache/tools/ant/taskdefs/Copy.java Index: Copy.java === RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/Copy.java,v retrieving revision 1.66.2.5 retrieving revision 1.66.2.6 diff -u -r1.66.2.5 -r1.66.2.6 --- Copy.java 25 May 2004 12:12:56 - 1.66.2.5 +++ Copy.java 1 Sep 2004 07:02:23 - 1.66.2.6 @@ -66,7 +66,7 @@ protected boolean flatten = false; protected int verbosity = Project.MSG_VERBOSE; protected boolean includeEmpty = true; -private boolean failonerror = true; +protected boolean failonerror = true; protected Hashtable fileCopyMap = new Hashtable(); protected Hashtable dirCopyMap = new Hashtable(); - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: cvs commit: ant/src/main/org/apache/tools/ant/taskdefs Copy.java
Hello Jan, I thought we wanted to have fields always private. This is what checkstyle checks. Cheers, Antoine jhm 2004/09/01 00:02:23 Modified:src/main/org/apache/tools/ant/taskdefs Tag: ANT_16_BRANCH Copy.java Log: Let move compile. Revision ChangesPath No revision No revision 1.66.2.6 +2 -2 ant/src/main/org/apache/tools/ant/taskdefs/Copy.java Index: Copy.java === RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/Copy.java,v retrieving revision 1.66.2.5 retrieving revision 1.66.2.6 diff -u -r1.66.2.5 -r1.66.2.6 --- Copy.java 25 May 2004 12:12:56 - 1.66.2.5 +++ Copy.java 1 Sep 2004 07:02:23 - 1.66.2.6 @@ -66,7 +66,7 @@ protected boolean flatten = false; protected int verbosity = Project.MSG_VERBOSE; protected boolean includeEmpty = true; -private boolean failonerror = true; +protected boolean failonerror = true; protected Hashtable fileCopyMap = new Hashtable(); protected Hashtable dirCopyMap = new Hashtable(); - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: cvs commit: ant/src/main/org/apache/tools/ant/taskdefs Copy.java
Thanks Jan, I was afraid I was forgetting something. :( -Matt --- [EMAIL PROTECTED] wrote: jhm 2004/08/31 22:38:54 Modified: src/main/org/apache/tools/ant/taskdefs Copy.java Log: Let move compile. Revision ChangesPath 1.73 +2 -3 ant/src/main/org/apache/tools/ant/taskdefs/Copy.java Index: Copy.java === RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/Copy.java,v retrieving revision 1.72 retrieving revision 1.73 diff -u -r1.72 -r1.73 --- Copy.java 25 May 2004 12:12:39 - 1.72 +++ Copy.java 1 Sep 2004 05:38:54 - 1.73 @@ -66,7 +66,7 @@ protected boolean flatten = false; protected int verbosity = Project.MSG_VERBOSE; protected boolean includeEmpty = true; -private boolean failonerror = true; +protected boolean failonerror = true; protected Hashtable fileCopyMap = new Hashtable(); protected Hashtable dirCopyMap = new Hashtable(); @@ -660,4 +660,3 @@ } } } - - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] __ Do you Yahoo!? Y! Messenger - Communicate in real time. Download now. http://messenger.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: ant/src/main/org/apache/tools/ant/taskdefs Copy.java Move.java
bodewig 2003/05/19 07:43:17 Modified:src/main/org/apache/tools/ant/taskdefs Copy.java Move.java Log: Don't remove basedirectories of filesets that just happen to be matched completely. PR: 18886 Revision ChangesPath 1.56 +3 -2 ant/src/main/org/apache/tools/ant/taskdefs/Copy.java Index: Copy.java === RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/Copy.java,v retrieving revision 1.55 retrieving revision 1.56 diff -u -r1.55 -r1.56 --- Copy.java 28 Mar 2003 08:06:53 - 1.55 +++ Copy.java 19 May 2003 14:43:17 - 1.56 @@ -391,7 +391,8 @@ String[] srcFiles = ds.getIncludedFiles(); String[] srcDirs = ds.getIncludedDirectories(); -boolean isEverythingIncluded = ds.isEverythingIncluded(); +boolean isEverythingIncluded = ds.isEverythingIncluded() + (!fs.hasSelectors() !fs.hasPatterns()); if (isEverythingIncluded !flatten mapperElement == null) { completeDirMap.put(fromDir, destDir); 1.34 +1 -66 ant/src/main/org/apache/tools/ant/taskdefs/Move.java Index: Move.java === RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/Move.java,v retrieving revision 1.33 retrieving revision 1.34 diff -u -r1.33 -r1.34 --- Move.java 27 Mar 2003 16:32:18 - 1.33 +++ Move.java 19 May 2003 14:43:17 - 1.34 @@ -213,71 +213,6 @@ + destDir.getAbsolutePath()); } } - -if (filesets.size() 0) { -Enumeration e = filesets.elements(); -while (e.hasMoreElements()) { -FileSet fs = (FileSet) e.nextElement(); -File dir = fs.getDir(getProject()); - -if (okToDelete(dir)) { -deleteDir(dir); -} -} -} -} - -/** - * Its only ok to delete a directory tree if there are - * no files in it. - * @return true if a deletion can go ahead - */ -protected boolean okToDelete(File d) { -String[] list = d.list(); -if (list == null) { -return false; -} // maybe io error? - -for (int i = 0; i list.length; i++) { -String s = list[i]; -File f = new File(d, s); -if (f.isDirectory()) { -if (!okToDelete(f)) { -return false; -} -} else { -return false; // found a file -} -} - -return true; -} - -/** - * Go and delete the directory tree. - */ -protected void deleteDir(File d) { -String[] list = d.list(); -if (list == null) { -return; -} // on an io error list() can return null - -for (int i = 0; i list.length; i++) { -String s = list[i]; -File f = new File(d, s); -if (f.isDirectory()) { -deleteDir(f); -} else { -throw new BuildException(UNEXPECTED ERROR - The file - + f.getAbsolutePath() - + should not exist!); -} -} -log(Deleting directory + d.getAbsolutePath(), verbosity); -if (!d.delete()) { -throw new BuildException(Unable to delete directory - + d.getAbsolutePath()); -} } /**
Re: cvs commit: ant/src/main/org/apache/tools/ant/taskdefs Copy.java Move.java
On 19 May 2003, [EMAIL PROTECTED] wrote: Don't remove basedirectories of filesets that just happen to be matched completely. This introduces a backwards incompatibility and maybe even inconsistency, that's why I haven't closed the bug report yet. I'm asking for feedback here. The bug report complains about this situation: move todir=foo fileset dir=bar includes=baz/ /move will remove the directory bar, if there is no other file but baz in in. If there happens to be a file zyzzy, the directory is retained. The complaint is that Ant could know that you didn't intend to move the whole set - you wouldn't have used includes otherwise. So now the above will retain the bar directory while move todir=foo fileset dir=bar/ /move will remove it. This seems to be consistent with the docs that say , | Move a set of files to a new directory | | move todir=some/new/dir | fileset dir=my/src/dir | include name=**/*.jar/ | exclude name=**/ant.jar/ | /fileset | /move ` and not move a complete directory tree if all files are included. Stefan
cvs commit: ant/src/main/org/apache/tools/ant/taskdefs Copy.java Move.java
bodewig 2003/05/19 08:21:15 Modified:.build.xml src/main/org/apache/tools/ant/taskdefs Copy.java Move.java Log: Remove directories explicitly matched with includes. PR: 11732 Revision ChangesPath 1.379 +0 -1 ant/build.xml Index: build.xml === RCS file: /home/cvs/ant/build.xml,v retrieving revision 1.378 retrieving revision 1.379 diff -u -r1.378 -r1.379 --- build.xml 19 May 2003 14:12:15 - 1.378 +++ build.xml 19 May 2003 15:21:14 - 1.379 @@ -276,7 +276,6 @@ patternset id=teststhatfail exclude name=${optional.package}/BeanShellScriptTest.java/ exclude name=${ant.package}/taskdefs/ImportTest.java/ -exclude name=${ant.package}/taskdefs/MoveTest.java/ /patternset !-- 1.57 +0 -0 ant/src/main/org/apache/tools/ant/taskdefs/Copy.java Index: Copy.java === RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/Copy.java,v retrieving revision 1.56 retrieving revision 1.57 diff -u -r1.56 -r1.57 1.35 +64 -5 ant/src/main/org/apache/tools/ant/taskdefs/Move.java Index: Move.java === RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/Move.java,v retrieving revision 1.34 retrieving revision 1.35 diff -u -r1.34 -r1.35 --- Move.java 19 May 2003 14:43:17 - 1.34 +++ Move.java 19 May 2003 15:21:15 - 1.35 @@ -194,24 +194,83 @@ } if (includeEmpty) { -Enumeration e = dirCopyMap.elements(); +Enumeration e = dirCopyMap.keys(); int count = 0; while (e.hasMoreElements()) { -File d = new File((String) e.nextElement()); -if (!d.exists()) { -if (!d.mkdirs()) { +String fromDirName = (String) e.nextElement(); +String toDirName = (String) dirCopyMap.get(fromDirName); +File fromDir = new File(fromDirName); +File toDir = new File(toDirName); +if (!toDir.exists()) { +if (!toDir.mkdirs()) { log(Unable to create directory -+ d.getAbsolutePath(), Project.MSG_ERR); ++ toDirName, Project.MSG_ERR); } else { count++; } } +if (okToDelete(fromDir)) { +deleteDir(fromDir); +} } if (count 0) { log(Moved + count + empty directories to + destDir.getAbsolutePath()); } +} +} + +/** + * Its only ok to delete a directory tree if there are + * no files in it. + * @return true if a deletion can go ahead + */ +protected boolean okToDelete(File d) { +String[] list = d.list(); +if (list == null) { +return false; +} // maybe io error? + +for (int i = 0; i list.length; i++) { +String s = list[i]; +File f = new File(d, s); +if (f.isDirectory()) { +if (!okToDelete(f)) { +return false; +} +} else { +return false; // found a file +} +} + +return true; +} + +/** + * Go and delete the directory tree. + */ +protected void deleteDir(File d) { +String[] list = d.list(); +if (list == null) { +return; +} // on an io error list() can return null + +for (int i = 0; i list.length; i++) { +String s = list[i]; +File f = new File(d, s); +if (f.isDirectory()) { +deleteDir(f); +} else { +throw new BuildException(UNEXPECTED ERROR - The file + + f.getAbsolutePath() + + should not exist!); +} +} +log(Deleting directory + d.getAbsolutePath(), verbosity); +if (!d.delete()) { +throw new BuildException(Unable to delete directory + + d.getAbsolutePath()); } }
cvs commit: ant/src/main/org/apache/tools/ant/taskdefs Copy.java
bodewig 2003/05/19 08:37:31 Modified:.WHATSNEW docs/manual/CoreTasks copy.html move.html src/main/org/apache/tools/ant/taskdefs Copy.java Log: Make copy's failonerror attribute swallow exception while copying as well. PR: 12999 Revision ChangesPath 1.422 +4 -0 ant/WHATSNEW Index: WHATSNEW === RCS file: /home/cvs/ant/WHATSNEW,v retrieving revision 1.421 retrieving revision 1.422 diff -u -r1.421 -r1.422 --- WHATSNEW 19 May 2003 12:18:07 - 1.421 +++ WHATSNEW 19 May 2003 15:37:31 - 1.422 @@ -358,6 +358,10 @@ * apply and chmod will display a summary if you set the new verbose attribute to true. Bugzilla Report 19883. +* copy/move's failonerror attribute can now also be used to + continue the build if an I/O error caused a problem. Bugzilla + Report 12999. + Changes from Ant 1.5.2 to Ant 1.5.3 === 1.18 +2 -1 ant/docs/manual/CoreTasks/copy.html Index: copy.html === RCS file: /home/cvs/ant/docs/manual/CoreTasks/copy.html,v retrieving revision 1.17 retrieving revision 1.18 diff -u -r1.17 -r1.18 --- copy.html 14 May 2003 11:53:41 - 1.17 +++ copy.html 19 May 2003 15:37:31 - 1.18 @@ -95,7 +95,8 @@ td valign=topfailonerror/td td valign=topLog a warning message, but do not stop the build, when the file to copy does not exist or one of the nested - filesets points to a directory that doesn't exist. + filesets points to a directory that doesn't exist or an error occurs + while copying. /td td valign=top align=centerNo; defaults to true./td /tr 1.13 +2 -1 ant/docs/manual/CoreTasks/move.html Index: move.html === RCS file: /home/cvs/ant/docs/manual/CoreTasks/move.html,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- move.html 14 May 2003 11:53:41 - 1.12 +++ move.html 19 May 2003 15:37:31 - 1.13 @@ -80,7 +80,8 @@ td valign=topfailonerror/td td valign=topLog a warning message, but do not stop the build, when the file to copy does not exist or one of the nested - filesets points to a directory that doesn't exist. + filesets points to a directory that doesn't exist or an error occurs + while moving. /td td valign=top align=centerNo; defaults to true./td /tr 1.58 +56 -48ant/src/main/org/apache/tools/ant/taskdefs/Copy.java Index: Copy.java === RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/Copy.java,v retrieving revision 1.57 retrieving revision 1.58 diff -u -r1.57 -r1.58 --- Copy.java 19 May 2003 15:21:15 - 1.57 +++ Copy.java 19 May 2003 15:37:31 - 1.58 @@ -401,7 +401,15 @@ } // do all the copy operations now... -doFileOperations(); +try { +doFileOperations(); +} catch (BuildException e) { +if (!failonerror) { +log(Warning: + e.getMessage(), Project.MSG_ERR); +} else { +throw e; +} +} } finally { // clean up again, so this instance can be used a second // time @@ -418,66 +426,66 @@ } } -// -// protected and private methods -// - -/** - * Ensure we have a consistent and legal set of attributes, and set - * any internal flags necessary based on different combinations - * of attributes. - */ -protected void validateAttributes() throws BuildException { -if (file == null filesets.size() == 0) { -throw new BuildException(Specify at least one source - + - a file or a fileset.); -} - -if (destFile != null destDir != null) { -throw new BuildException(Only one of tofile and todir - + may be set.); -} + // +// protected and private methods + // + +/** + * Ensure we have a consistent and legal set of attributes, and set + * any internal flags necessary
cvs commit: ant/src/main/org/apache/tools/ant/taskdefs Copy.java
bodewig 2003/05/19 08:41:23 Modified:src/main/org/apache/tools/ant/taskdefs Copy.java Log: revert funny reformatting accidentially introduced with last commit Revision ChangesPath 1.59 +50 -50ant/src/main/org/apache/tools/ant/taskdefs/Copy.java Index: Copy.java === RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/Copy.java,v retrieving revision 1.58 retrieving revision 1.59 diff -u -r1.58 -r1.59 --- Copy.java 19 May 2003 15:37:31 - 1.58 +++ Copy.java 19 May 2003 15:41:22 - 1.59 @@ -426,66 +426,66 @@ } } - // -// protected and private methods - // - -/** - * Ensure we have a consistent and legal set of attributes, and set - * any internal flags necessary based on different combinations - * of attributes. - */ -protected void validateAttributes() throws BuildException { -if (file == null filesets.size() == 0) { -throw new BuildException(Specify at least one source - + - a file or a fileset.); -} - -if (destFile != null destDir != null) { -throw new BuildException(Only one of tofile and todir - + may be set.); -} - -if (destFile == null destDir == null) { -throw new BuildException(One of tofile or todir must be set.); -} - -if (file != null file.exists() file.isDirectory()) { -throw new BuildException(Use a fileset to copy directories.); -} +/ + ** protected and private methods + / + +/** + * Ensure we have a consistent and legal set of attributes, and set + * any internal flags necessary based on different combinations + * of attributes. + */ +protected void validateAttributes() throws BuildException { +if (file == null filesets.size() == 0) { +throw new BuildException(Specify at least one source + + - a file or a fileset.); +} + +if (destFile != null destDir != null) { +throw new BuildException(Only one of tofile and todir + + may be set.); +} + +if (destFile == null destDir == null) { +throw new BuildException(One of tofile or todir must be set.); +} + +if (file != null file.exists() file.isDirectory()) { +throw new BuildException(Use a fileset to copy directories.); +} + +if (destFile != null filesets.size() 0) { +if (filesets.size() 1) { +throw new BuildException( + Cannot concatenate multiple files into a single file.); +} else { +FileSet fs = (FileSet) filesets.elementAt(0); +DirectoryScanner ds = fs.getDirectoryScanner(getProject()); +String[] srcFiles = ds.getIncludedFiles(); -if (destFile != null filesets.size() 0) { -if (filesets.size() 1) { +if (srcFiles.length == 0) { throw new BuildException( - Cannot concatenate multiple files into a single file.); -} else { -FileSet fs = (FileSet) filesets.elementAt(0); -DirectoryScanner ds = fs.getDirectoryScanner(getProject()); -String[] srcFiles = ds.getIncludedFiles(); - -if (srcFiles.length == 0) { -throw new BuildException( - Cannot perform operation from directory to file.); -} else if (srcFiles.length == 1) { -if (file == null) { -file = new File(ds.getBasedir(), srcFiles[0]); -filesets.removeElementAt(0); -} else { -throw new BuildException(Cannot concatenate multiple - + files into a single file.); -} + Cannot perform operation from directory to file.); +
Re: cvs commit: ant/src/main/org/apache/tools/ant/taskdefs Copy.java
On 28 Mar 2003, [EMAIL PROTECTED] wrote: - public void setFailOnError(boolean failonerror) { - this.failonerror = failonerror; - } +public void setFailOnError(boolean failonerror) { +this.failonerror = failonerror; +} I have no idea what's happened here, especially since I've made the last commit to that file yesterday and can't remember running a code formatter over it after that (or something similar). Stefan