cvs commit: ant/src/main/org/apache/tools/ant/taskdefs/optional/unix Symlink.java
mbenson 2005/02/11 08:53:00 Modified:src/main/org/apache/tools/ant/taskdefs/optional/unix Symlink.java Log: Instantiate our own DirectoryScanner, since we plan to override the fileset's followSymlinks attribute. Revision ChangesPath 1.26 +3 -2 ant/src/main/org/apache/tools/ant/taskdefs/optional/unix/Symlink.java Index: Symlink.java === RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/optional/unix/Symlink.java,v retrieving revision 1.25 retrieving revision 1.26 diff -u -r1.25 -r1.26 --- Symlink.java 4 Feb 2005 14:56:51 - 1.25 +++ Symlink.java 11 Feb 2005 16:53:00 - 1.26 @@ -551,7 +551,8 @@ // loop through the supplied file sets: for (int i = 0; i v.size(); i++) { FileSet fs = (FileSet) v.elementAt(i); -DirectoryScanner ds = fs.getDirectoryScanner(this.getProject()); +DirectoryScanner ds = new DirectoryScanner(); +fs.setupDirectoryScanner(ds, getProject()); ds.setFollowSymlinks(false); ds.scan(); String[] incs = ds.getIncludedFiles(); - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: ant/src/main/org/apache/tools/ant/taskdefs/optional/unix Symlink.java
bodewig 2005/02/04 06:56:51 Modified:src/main/org/apache/tools/ant/taskdefs/optional/unix Symlink.java Log: More Jikes whining Revision ChangesPath 1.25 +2 -2 ant/src/main/org/apache/tools/ant/taskdefs/optional/unix/Symlink.java Index: Symlink.java === RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/optional/unix/Symlink.java,v retrieving revision 1.24 retrieving revision 1.25 diff -u -r1.24 -r1.25 --- Symlink.java 3 Feb 2005 17:59:34 - 1.24 +++ Symlink.java 4 Feb 2005 14:56:51 - 1.25 @@ -457,7 +457,7 @@ } catch (IOException ioe) { throw new BuildException(ioe, getLocation()); } finally { -FILE_UTILS.close(bos); +FileUtils.close(bos); } } - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: ant/src/main/org/apache/tools/ant/taskdefs/optional/unix Symlink.java
mbenson 2005/02/03 09:58:11 Modified:src/main/org/apache/tools/ant/taskdefs/optional/unix Symlink.java Log: Revamp symlink task: Extend DispatchTask Remove 1.1 stuff / use 1.2 features where helpful Javadoc bumming Revision ChangesPath 1.23 +262 -407 ant/src/main/org/apache/tools/ant/taskdefs/optional/unix/Symlink.java Index: Symlink.java === RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/optional/unix/Symlink.java,v retrieving revision 1.22 retrieving revision 1.23 diff -u -r1.22 -r1.23 --- Symlink.java 28 Jan 2005 16:12:37 - 1.22 +++ Symlink.java 3 Feb 2005 17:58:11 - 1.23 @@ -30,27 +30,33 @@ import java.io.File; import java.io.IOException; +import java.io.PrintStream; import java.io.FileInputStream; import java.io.FileOutputStream; +import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; import java.io.FileNotFoundException; import java.util.Vector; -import java.util.Properties; -import java.util.Enumeration; +import java.util.HashSet; +import java.util.Iterator; import java.util.Hashtable; +import java.util.Properties; 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.util.FileUtils; - -import org.apache.tools.ant.types.FileSet; - +import org.apache.tools.ant.dispatch.DispatchTask; +import org.apache.tools.ant.dispatch.DispatchUtils; import org.apache.tools.ant.taskdefs.Execute; +import org.apache.tools.ant.taskdefs.LogOutputStream; +import org.apache.tools.ant.types.FileSet; +import org.apache.tools.ant.types.Commandline; +import org.apache.tools.ant.util.FileUtils; /** - * Creates, Records and Restores Symlinks. + * Creates, Deletes, Records and Restores Symlinks. * * p This task performs several related operations. In the most trivial * and default usage, it creates a link specified in the link attribute to @@ -61,10 +67,9 @@ * directory structure specified by a fileset, looking for properties files * (also specified as included in the fileset) and recreate the links * that have been previously recorded for each directory. Finally, it can be - * used to remove a symlink without deleting the file or directory it points - * to. + * used to remove a symlink without deleting the associated resource. * - * p Examples of use: + * p Usage examples: * * p Make a link named quot;fooquot; to a resource named * quot;bar.fooquot; in subdir: @@ -73,7 +78,7 @@ * /pre * * p Record all links in subdir and its descendants in files named - * quot;dir.linksquot; + * quot;dir.linksquot;: * pre * lt;symlink action=quot;recordquot; linkfilename=quot;dir.linksquot;gt; *lt;fileset dir=quot;${dir.top}quot; includes=quot;subdir#47;**quot; /gt; @@ -98,7 +103,7 @@ * absolute paths. On non-unix systems this may cause false positives. * Furthermore, any operating system on which the command * codeln -s link resource/code is not a valid command on the command line - * will not be able to use action= quot;deletequot;, action=quot;singlequot; + * will not be able to use action=quot;deletequot;, action=quot;singlequot; * or action=quot;recreatequot;, but action=quot;recordquot; should still * work. Finally, the lack of support for symlinks in Java means that all links * are recorded as links to the strongcanonical/strong resource name. @@ -108,18 +113,16 @@ * * @version $Revision$ */ -public class Symlink extends Task { +public class Symlink extends DispatchTask { +private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); -// Attributes with setter methods: private String resource; private String link; -private String action; private Vector fileSets = new Vector(); private String linkFileName; private boolean overwrite; private boolean failonerror; - -private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); +private boolean executing = false; /** * Initialize the task. @@ -127,146 +130,169 @@ */ public void init() throws BuildException { super.init(); -failonerror = true; // default behavior is to fail on an error -overwrite = false;// default behavior is to not overwrite -action = single; // default behavior is make a single link -fileSets = new Vector(); +setDefaults(); } /** * The standard method for executing any task. * @throws BuildException on error. */ -public void execute() throws
cvs commit: ant/src/main/org/apache/tools/ant/taskdefs/optional/unix Symlink.java
mbenson 2005/02/03 09:59:34 Modified:src/main/org/apache/tools/ant/taskdefs/optional/unix Symlink.java Log: Add 1.7 tags to dispatch methods. Revision ChangesPath 1.24 +5 -1 ant/src/main/org/apache/tools/ant/taskdefs/optional/unix/Symlink.java Index: Symlink.java === RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/optional/unix/Symlink.java,v retrieving revision 1.23 retrieving revision 1.24 diff -u -r1.23 -r1.24 --- Symlink.java 3 Feb 2005 17:58:11 - 1.23 +++ Symlink.java 3 Feb 2005 17:59:34 - 1.24 @@ -153,6 +153,7 @@ /** * Create a symlink. * @throws BuildException on error. + * @since Ant 1.7 */ public void single() throws BuildException { try { @@ -173,6 +174,7 @@ /** * Delete a symlink. * @throws BuildException on error. + * @since Ant 1.7 */ public void delete() throws BuildException { try { @@ -194,6 +196,7 @@ /** * Restore symlinks. * @throws BuildException on error. + * @since Ant 1.7 */ public void recreate() throws BuildException { try { @@ -229,6 +232,7 @@ /** * Record symlinks. * @throws BuildException on error. + * @since Ant 1.7 */ public void record() throws BuildException { try { - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: ant/src/main/org/apache/tools/ant/taskdefs/optional/unix Symlink.java
mbenson 2005/01/28 08:12:37 Modified:src/main/org/apache/tools/ant/taskdefs/optional/unix Symlink.java Log: More javadoc Revision ChangesPath 1.22 +43 -40 ant/src/main/org/apache/tools/ant/taskdefs/optional/unix/Symlink.java Index: Symlink.java === RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/optional/unix/Symlink.java,v retrieving revision 1.21 retrieving revision 1.22 diff -u -r1.21 -r1.22 --- Symlink.java 27 Jan 2005 23:45:29 - 1.21 +++ Symlink.java 28 Jan 2005 16:12:37 - 1.22 @@ -66,29 +66,31 @@ * * p Examples of use: * - * p Make a link named foo to a resource named bar.foo in subdir: + * p Make a link named quot;fooquot; to a resource named + * quot;bar.fooquot; in subdir: * pre - * lt;symlink link=${dir.top}/foo resource=${dir.top}/subdir/bar.foo/gt; + * lt;symlink link=quot;${dir.top}/fooquot; resource=quot;${dir.top}/subdir/bar.fooquot;/gt; * /pre * - * p Record all links in subdir and it's descendants in files named - * dir.links + * p Record all links in subdir and its descendants in files named + * quot;dir.linksquot; * pre - * lt;symlink action=record linkfilename=dir.linksgt; - *lt;fileset dir=${dir.top} includes=subdir#47;** /gt; + * lt;symlink action=quot;recordquot; linkfilename=quot;dir.linksquot;gt; + *lt;fileset dir=quot;${dir.top}quot; includes=quot;subdir#47;**quot; /gt; * lt;/symlinkgt; * /pre * * p Recreate the links recorded in the previous example: * pre - * lt;symlink action=recreategt; - *lt;fileset dir=${dir.top} includes=subdir#47;**#47;dir.links /gt; + * lt;symlink action=quot;recreatequot;gt; + *lt;fileset dir=quot;${dir.top}quot; includes=quot;subdir#47;**#47;dir.linksquot; /gt; * lt;/symlinkgt; * /pre * - * p Delete a link named foo to a resource named bar.foo in subdir: + * p Delete a link named quot;fooquot; to a resource named + * quot;bar.fooquot; in subdir: * pre - * lt;symlink action=delete link=${dir.top}/foo/gt; + * lt;symlink action=quot;deletequot; link=quot;${dir.top}/fooquot;/gt; * /pre * * pstrongLIMITATIONS:/strong Because Java has no direct support for @@ -96,17 +98,16 @@ * absolute paths. On non-unix systems this may cause false positives. * Furthermore, any operating system on which the command * codeln -s link resource/code is not a valid command on the command line - * will not be able to use action= delete, action=single or - * action=recreate, but action=record should still work. Finally, the - * lack of support for symlinks in Java means that all links are recorded - * as links to the strongcanonical/strong resource name. Therefore - * the link: codelink -- subdir/dir/../foo.bar/code will be recorded - * as codelink=subdir/foo.bar/code and restored as - * codelink -- subdir/foo.bar/code + * will not be able to use action= quot;deletequot;, action=quot;singlequot; + * or action=quot;recreatequot;, but action=quot;recordquot; should still + * work. Finally, the lack of support for symlinks in Java means that all links + * are recorded as links to the strongcanonical/strong resource name. + * Therefore the link: codelink -- subdir/dir/../foo.bar/code will be + * recorded as codelink=subdir/foo.bar/code and restored as + * codelink -- subdir/foo.bar/code. * * @version $Revision$ */ - public class Symlink extends Task { // Attributes with setter methods: @@ -120,8 +121,10 @@ private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); -/** Initialize the task. */ - +/** + * Initialize the task. + * @throws BuildException on error. + */ public void init() throws BuildException { super.init(); failonerror = true; // default behavior is to fail on an error @@ -285,17 +288,18 @@ } /** - * The setter for the action attribute. May be single, multi - * or record + * Set the action to be performed. May be + * quot;singlequot;, quot;multiquot; or quot;recordquot;. * - * @param typThe action of action to perform. + * @param typThe action to perform. */ public void setAction(String typ) { this.action = typ; } /** - * The setter for the link attribute. Only used for action = single. + * Set the same of the link. + * Only used when action = quot;singlequot;. * * @param lnk The name for the link. */ @@ -304,16 +308,18 @@ } /** - * The setter for the resource attribute. Only used for action = single. + * Set the name of the resource to which a link should be created. + * Only used when
cvs commit: ant/src/main/org/apache/tools/ant/taskdefs/optional/unix Symlink.java
mbenson 2005/01/28 08:27:47 Modified:src/main/org/apache/tools/ant/taskdefs/optional/unix Tag: ANT_16_BRANCH Symlink.java Log: Merge Revision ChangesPath No revision No revision 1.12.2.8 +43 -40 ant/src/main/org/apache/tools/ant/taskdefs/optional/unix/Symlink.java Index: Symlink.java === RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/optional/unix/Symlink.java,v retrieving revision 1.12.2.7 retrieving revision 1.12.2.8 diff -u -r1.12.2.7 -r1.12.2.8 --- Symlink.java 27 Jan 2005 23:48:32 - 1.12.2.7 +++ Symlink.java 28 Jan 2005 16:27:47 - 1.12.2.8 @@ -66,29 +66,31 @@ * * p Examples of use: * - * p Make a link named foo to a resource named bar.foo in subdir: + * p Make a link named quot;fooquot; to a resource named + * quot;bar.fooquot; in subdir: * pre - * lt;symlink link=${dir.top}/foo resource=${dir.top}/subdir/bar.foo/gt; + * lt;symlink link=quot;${dir.top}/fooquot; resource=quot;${dir.top}/subdir/bar.fooquot;/gt; * /pre * - * p Record all links in subdir and it's descendants in files named - * dir.links + * p Record all links in subdir and its descendants in files named + * quot;dir.linksquot; * pre - * lt;symlink action=record linkfilename=dir.linksgt; - *lt;fileset dir=${dir.top} includes=subdir#47;** /gt; + * lt;symlink action=quot;recordquot; linkfilename=quot;dir.linksquot;gt; + *lt;fileset dir=quot;${dir.top}quot; includes=quot;subdir#47;**quot; /gt; * lt;/symlinkgt; * /pre * * p Recreate the links recorded in the previous example: * pre - * lt;symlink action=recreategt; - *lt;fileset dir=${dir.top} includes=subdir#47;**#47;dir.links /gt; + * lt;symlink action=quot;recreatequot;gt; + *lt;fileset dir=quot;${dir.top}quot; includes=quot;subdir#47;**#47;dir.linksquot; /gt; * lt;/symlinkgt; * /pre * - * p Delete a link named foo to a resource named bar.foo in subdir: + * p Delete a link named quot;fooquot; to a resource named + * quot;bar.fooquot; in subdir: * pre - * lt;symlink action=delete link=${dir.top}/foo/gt; + * lt;symlink action=quot;deletequot; link=quot;${dir.top}/fooquot;/gt; * /pre * * pstrongLIMITATIONS:/strong Because Java has no direct support for @@ -96,17 +98,16 @@ * absolute paths. On non-unix systems this may cause false positives. * Furthermore, any operating system on which the command * codeln -s link resource/code is not a valid command on the command line - * will not be able to use action= delete, action=single or - * action=recreate, but action=record should still work. Finally, the - * lack of support for symlinks in Java means that all links are recorded - * as links to the strongcanonical/strong resource name. Therefore - * the link: codelink -- subdir/dir/../foo.bar/code will be recorded - * as codelink=subdir/foo.bar/code and restored as - * codelink -- subdir/foo.bar/code + * will not be able to use action= quot;deletequot;, action=quot;singlequot; + * or action=quot;recreatequot;, but action=quot;recordquot; should still + * work. Finally, the lack of support for symlinks in Java means that all links + * are recorded as links to the strongcanonical/strong resource name. + * Therefore the link: codelink -- subdir/dir/../foo.bar/code will be + * recorded as codelink=subdir/foo.bar/code and restored as + * codelink -- subdir/foo.bar/code. * * @version $Revision$ */ - public class Symlink extends Task { // Attributes with setter methods: @@ -120,8 +121,10 @@ private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); -/** Initialize the task. */ - +/** + * Initialize the task. + * @throws BuildException on error. + */ public void init() throws BuildException { super.init(); failonerror = true; // default behavior is to fail on an error @@ -285,17 +288,18 @@ } /** - * The setter for the action attribute. May be single, multi - * or record + * Set the action to be performed. May be + * quot;singlequot;, quot;multiquot; or quot;recordquot;. * - * @param typThe action of action to perform. + * @param typThe action to perform. */ public void setAction(String typ) { this.action = typ; } /** - * The setter for the link attribute. Only used for action = single. + * Set the same of the link. + * Only used when action = quot;singlequot;. * * @param lnk The name for the link. */ @@ -304,16 +308,18 @@ } /** - * The setter for the resource attribute. Only used for action =
cvs commit: ant/src/main/org/apache/tools/ant/taskdefs/optional/unix Symlink.java
mbenson 2005/01/27 15:45:29 Modified:src/main/org/apache/tools/ant/taskdefs/optional/unix Symlink.java Log: Some javadoc and lots of spelling corrections. Revision ChangesPath 1.21 +54 -94 ant/src/main/org/apache/tools/ant/taskdefs/optional/unix/Symlink.java Index: Symlink.java === RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/optional/unix/Symlink.java,v retrieving revision 1.20 retrieving revision 1.21 diff -u -r1.20 -r1.21 --- Symlink.java 6 Jan 2005 12:05:07 - 1.20 +++ Symlink.java 27 Jan 2005 23:45:29 - 1.21 @@ -16,7 +16,7 @@ */ /* - * Since the initial version of this file was deveolped on the clock on + * Since the initial version of this file was developed on the clock on * an NSF grant I should say the following boilerplate: * * This material is based upon work supported by the National Science @@ -52,10 +52,10 @@ /** * Creates, Records and Restores Symlinks. * - * p This task performs several related operations. In the most trivial, - * and default usage, it creates a link specified in the link atribute to - * a resource specified in the resource atribute. The second usage of this - * task is to traverses a directory structure specified by a fileset, + * p This task performs several related operations. In the most trivial + * and default usage, it creates a link specified in the link attribute to + * a resource specified in the resource attribute. The second usage of this + * task is to traverse a directory structure specified by a fileset, * and write a properties file in each included directory describing the * links found in that directory. The third usage is to traverse a * directory structure specified by a fileset, looking for properties files @@ -92,10 +92,10 @@ * /pre * * pstrongLIMITATIONS:/strong Because Java has no direct support for - * handling symlinks this task divines them by comparing canoniacal and + * handling symlinks this task divines them by comparing canonical and * absolute paths. On non-unix systems this may cause false positives. * Furthermore, any operating system on which the command - * codeln -s link resource/code is not a valid command on the comandline + * codeln -s link resource/code is not a valid command on the command line * will not be able to use action= delete, action=single or * action=recreate, but action=record should still work. Finally, the * lack of support for symlinks in Java means that all links are recorded @@ -109,7 +109,7 @@ public class Symlink extends Task { -// Atributes with setter methods +// Attributes with setter methods: private String resource; private String link; private String action; @@ -119,19 +119,21 @@ private boolean failonerror; private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); - + /** Initialize the task. */ public void init() throws BuildException { super.init(); failonerror = true; // default behavior is to fail on an error -overwrite = false;// devault behavior is to not overwrite +overwrite = false;// default behavior is to not overwrite action = single; // default behavior is make a single link fileSets = new Vector(); } -/** The standard method for executing any task. */ - +/** + * The standard method for executing any task. + * @throws BuildException on error. + */ public void execute() throws BuildException { try { if (action.equals(single)) { @@ -154,7 +156,6 @@ + required for action recreate); return; } - listOfLinks = loadLinks(fileSets); keys = listOfLinks.keys(); @@ -188,17 +189,15 @@ Enumeration links, dirs; if (fileSets.size() == 0) { -handleError(File set identifying links to +handleError(Fileset identifying links to + record required); return; } - if (linkFileName == null) { handleError(Name of file to record links in + required); return; } - // fill our vector with file objects representing // links (canonical) vectOfLinks = findLinks(fileSets); @@ -215,7 +214,6 @@ ((Vector) byDir.get(parent)).addElement(thisLink); } }
cvs commit: ant/src/main/org/apache/tools/ant/taskdefs/optional/unix Symlink.java
mbenson 2005/01/27 15:48:32 Modified:src/main/org/apache/tools/ant/taskdefs/optional/unix Tag: ANT_16_BRANCH Symlink.java Log: Merge Revision ChangesPath No revision No revision 1.12.2.7 +80 -120 ant/src/main/org/apache/tools/ant/taskdefs/optional/unix/Symlink.java Index: Symlink.java === RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/optional/unix/Symlink.java,v retrieving revision 1.12.2.6 retrieving revision 1.12.2.7 diff -u -r1.12.2.6 -r1.12.2.7 --- Symlink.java 7 Jun 2004 12:03:55 - 1.12.2.6 +++ Symlink.java 27 Jan 2005 23:48:32 - 1.12.2.7 @@ -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. @@ -16,7 +16,7 @@ */ /* - * Since the initial version of this file was deveolped on the clock on + * Since the initial version of this file was developed on the clock on * an NSF grant I should say the following boilerplate: * * This material is based upon work supported by the National Science @@ -52,10 +52,10 @@ /** * Creates, Records and Restores Symlinks. * - * p This task performs several related operations. In the most trivial, - * and default usage, it creates a link specified in the link atribute to - * a resource specified in the resource atribute. The second usage of this - * task is to traverses a directory structure specified by a fileset, + * p This task performs several related operations. In the most trivial + * and default usage, it creates a link specified in the link attribute to + * a resource specified in the resource attribute. The second usage of this + * task is to traverse a directory structure specified by a fileset, * and write a properties file in each included directory describing the * links found in that directory. The third usage is to traverse a * directory structure specified by a fileset, looking for properties files @@ -92,10 +92,10 @@ * /pre * * pstrongLIMITATIONS:/strong Because Java has no direct support for - * handling symlinks this task divines them by comparing canoniacal and + * handling symlinks this task divines them by comparing canonical and * absolute paths. On non-unix systems this may cause false positives. * Furthermore, any operating system on which the command - * codeln -s link resource/code is not a valid command on the comandline + * codeln -s link resource/code is not a valid command on the command line * will not be able to use action= delete, action=single or * action=recreate, but action=record should still work. Finally, the * lack of support for symlinks in Java means that all links are recorded @@ -109,7 +109,7 @@ public class Symlink extends Task { -// Atributes with setter methods +// Attributes with setter methods: private String resource; private String link; private String action; @@ -118,18 +118,22 @@ private boolean overwrite; private boolean failonerror; +private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); + /** Initialize the task. */ public void init() throws BuildException { super.init(); failonerror = true; // default behavior is to fail on an error -overwrite = false;// devault behavior is to not overwrite +overwrite = false;// default behavior is to not overwrite action = single; // default behavior is make a single link fileSets = new Vector(); } -/** The standard method for executing any task. */ - +/** + * The standard method for executing any task. + * @throws BuildException on error. + */ public void execute() throws BuildException { try { if (action.equals(single)) { @@ -152,7 +156,6 @@ + required for action recreate); return; } - listOfLinks = loadLinks(fileSets); keys = listOfLinks.keys(); @@ -160,26 +163,25 @@ while (keys.hasMoreElements()) { link = (String) keys.nextElement(); resource = listOfLinks.getProperty(link); - // handle the case where the link exists - // and points to a directory (bug 25181) - try { - FileUtils fu = FileUtils.newFileUtils(); - File test = new File(link); - File testRes = new
cvs commit: ant/src/main/org/apache/tools/ant/taskdefs/optional/unix Symlink.java
bodewig 2003/10/14 06:19:53 Modified:src/main/org/apache/tools/ant/taskdefs FixCRLF.java Javadoc.java Replace.java Zip.java src/main/org/apache/tools/ant/taskdefs/compilers DefaultCompilerAdapter.java src/main/org/apache/tools/ant/taskdefs/cvslib CvsTagDiff.java src/main/org/apache/tools/ant/taskdefs/optional Cab.java ReplaceRegExp.java src/main/org/apache/tools/ant/taskdefs/optional/junit JUnitTask.java src/main/org/apache/tools/ant/taskdefs/optional/metamata AbstractMetamataTask.java src/main/org/apache/tools/ant/taskdefs/optional/net FTP.java src/main/org/apache/tools/ant/taskdefs/optional/sitraka CovMerge.java Coverage.java src/main/org/apache/tools/ant/taskdefs/optional/unix Symlink.java Log: More robust cleanup of temporary files, PR 17512 Revision ChangesPath 1.55 +2 -1 ant/src/main/org/apache/tools/ant/taskdefs/FixCRLF.java Index: FixCRLF.java === RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/FixCRLF.java,v retrieving revision 1.54 retrieving revision 1.55 diff -u -r1.54 -r1.55 --- FixCRLF.java 16 Sep 2003 09:08:55 - 1.54 +++ FixCRLF.java 14 Oct 2003 13:19:52 - 1.55 @@ -404,6 +404,7 @@ // Set up the output Writer try { tmpFile = fileUtils.createTempFile(fixcrlf, , null); +tmpFile.deleteOnExit(); Writer writer = (encoding == null) ? new FileWriter(tmpFile) : new OutputStreamWriter(new FileOutputStream(tmpFile), encoding); 1.125 +1 -0 ant/src/main/org/apache/tools/ant/taskdefs/Javadoc.java Index: Javadoc.java === RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/Javadoc.java,v retrieving revision 1.124 retrieving revision 1.125 diff -u -r1.124 -r1.125 --- Javadoc.java 16 Sep 2003 09:08:55 - 1.124 +++ Javadoc.java 14 Oct 2003 13:19:52 - 1.125 @@ -1919,6 +1919,7 @@ if (useExternalFile) { if (tmpList == null) { tmpList = fileUtils.createTempFile(javadoc, , null); +tmpList.deleteOnExit(); toExecute.createArgument() .setValue(@ + tmpList.getAbsolutePath()); } 1.48 +1 -0 ant/src/main/org/apache/tools/ant/taskdefs/Replace.java Index: Replace.java === RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/Replace.java,v retrieving revision 1.47 retrieving revision 1.48 diff -u -r1.47 -r1.48 --- Replace.java 13 Aug 2003 14:46:15 - 1.47 +++ Replace.java 14 Oct 2003 13:19:52 - 1.48 @@ -399,6 +399,7 @@ File temp = fileUtils.createTempFile(rep, .tmp, fileUtils.getParentFile(src)); +temp.deleteOnExit(); Reader reader = null; Writer writer = null; 1.117 +1 -0 ant/src/main/org/apache/tools/ant/taskdefs/Zip.java Index: Zip.java === RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/Zip.java,v retrieving revision 1.116 retrieving revision 1.117 diff -u -r1.116 -r1.117 --- Zip.java 16 Sep 2003 09:08:56 - 1.116 +++ Zip.java 14 Oct 2003 13:19:52 - 1.117 @@ -416,6 +416,7 @@ renamedFile = fileUtils.createTempFile(zip, .tmp, fileUtils.getParentFile(zipFile)); +renamedFile.deleteOnExit(); try { fileUtils.rename(zipFile, renamedFile); 1.42 +1 -0 ant/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java Index: DefaultCompilerAdapter.java === RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java,v retrieving revision 1.41 retrieving revision 1.42 diff -u -r1.41 -r1.42 --- DefaultCompilerAdapter.java 16 Sep 2003 09:08:57 - 1.41 +++ DefaultCompilerAdapter.java 14 Oct 2003 13:19:52 - 1.42 @@ -445,6 +445,7 @@ userDir = new File(userDirName); }
cvs commit: ant/src/main/org/apache/tools/ant/taskdefs/optional/unix Symlink.java
bodewig 2003/10/14 06:20:12 Modified:src/main/org/apache/tools/ant/taskdefs Tag: ANT_16_BRANCH FixCRLF.java Javadoc.java Replace.java Zip.java src/main/org/apache/tools/ant/taskdefs/compilers Tag: ANT_16_BRANCH DefaultCompilerAdapter.java src/main/org/apache/tools/ant/taskdefs/cvslib Tag: ANT_16_BRANCH CvsTagDiff.java src/main/org/apache/tools/ant/taskdefs/optional Tag: ANT_16_BRANCH Cab.java ReplaceRegExp.java src/main/org/apache/tools/ant/taskdefs/optional/junit Tag: ANT_16_BRANCH JUnitTask.java src/main/org/apache/tools/ant/taskdefs/optional/metamata Tag: ANT_16_BRANCH AbstractMetamataTask.java src/main/org/apache/tools/ant/taskdefs/optional/net Tag: ANT_16_BRANCH FTP.java src/main/org/apache/tools/ant/taskdefs/optional/sitraka Tag: ANT_16_BRANCH CovMerge.java Coverage.java src/main/org/apache/tools/ant/taskdefs/optional/unix Tag: ANT_16_BRANCH Symlink.java Log: Merge from HEAD Revision ChangesPath No revision No revision 1.54.2.1 +2 -1 ant/src/main/org/apache/tools/ant/taskdefs/FixCRLF.java Index: FixCRLF.java === RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/FixCRLF.java,v retrieving revision 1.54 retrieving revision 1.54.2.1 diff -u -r1.54 -r1.54.2.1 --- FixCRLF.java 16 Sep 2003 09:08:55 - 1.54 +++ FixCRLF.java 14 Oct 2003 13:20:11 - 1.54.2.1 @@ -404,6 +404,7 @@ // Set up the output Writer try { tmpFile = fileUtils.createTempFile(fixcrlf, , null); +tmpFile.deleteOnExit(); Writer writer = (encoding == null) ? new FileWriter(tmpFile) : new OutputStreamWriter(new FileOutputStream(tmpFile), encoding); 1.124.2.1 +1 -0 ant/src/main/org/apache/tools/ant/taskdefs/Javadoc.java Index: Javadoc.java === RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/Javadoc.java,v retrieving revision 1.124 retrieving revision 1.124.2.1 diff -u -r1.124 -r1.124.2.1 --- Javadoc.java 16 Sep 2003 09:08:55 - 1.124 +++ Javadoc.java 14 Oct 2003 13:20:11 - 1.124.2.1 @@ -1919,6 +1919,7 @@ if (useExternalFile) { if (tmpList == null) { tmpList = fileUtils.createTempFile(javadoc, , null); +tmpList.deleteOnExit(); toExecute.createArgument() .setValue(@ + tmpList.getAbsolutePath()); } 1.47.2.1 +1 -0 ant/src/main/org/apache/tools/ant/taskdefs/Replace.java Index: Replace.java === RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/Replace.java,v retrieving revision 1.47 retrieving revision 1.47.2.1 diff -u -r1.47 -r1.47.2.1 --- Replace.java 13 Aug 2003 14:46:15 - 1.47 +++ Replace.java 14 Oct 2003 13:20:11 - 1.47.2.1 @@ -399,6 +399,7 @@ File temp = fileUtils.createTempFile(rep, .tmp, fileUtils.getParentFile(src)); +temp.deleteOnExit(); Reader reader = null; Writer writer = null; 1.116.2.1 +1 -0 ant/src/main/org/apache/tools/ant/taskdefs/Zip.java Index: Zip.java === RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/Zip.java,v retrieving revision 1.116 retrieving revision 1.116.2.1 diff -u -r1.116 -r1.116.2.1 --- Zip.java 16 Sep 2003 09:08:56 - 1.116 +++ Zip.java 14 Oct 2003 13:20:11 - 1.116.2.1 @@ -416,6 +416,7 @@ renamedFile = fileUtils.createTempFile(zip, .tmp, fileUtils.getParentFile(zipFile)); +renamedFile.deleteOnExit(); try { fileUtils.rename(zipFile, renamedFile); No revision No revision 1.41.2.1 +1 -0 ant/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java Index: DefaultCompilerAdapter.java === RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java,v
cvs commit: ant/src/main/org/apache/tools/ant/taskdefs/optional/unix Symlink.java
bodewig 2003/06/25 04:52:48 Modified:src/main/org/apache/tools/ant/taskdefs Rename.java Replace.java Zip.java src/main/org/apache/tools/ant/taskdefs/optional ReplaceRegExp.java src/main/org/apache/tools/ant/taskdefs/optional/ejb WeblogicDeploymentTool.java WebsphereDeploymentTool.java src/main/org/apache/tools/ant/taskdefs/optional/unix Symlink.java Log: Use the new FileUtils#rename method Revision ChangesPath 1.14 +10 -8 ant/src/main/org/apache/tools/ant/taskdefs/Rename.java Index: Rename.java === RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/Rename.java,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- Rename.java 10 Feb 2003 14:13:36 - 1.13 +++ Rename.java 25 Jun 2003 11:52:46 - 1.14 @@ -1,7 +1,7 @@ /* * The Apache Software License, Version 1.1 * - * Copyright (c) 2000-2002 The Apache Software Foundation. All rights + * Copyright (c) 2000-2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -55,9 +55,11 @@ package org.apache.tools.ant.taskdefs; import java.io.File; +import java.io.IOException; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.Project; import org.apache.tools.ant.Task; +import org.apache.tools.ant.util.FileUtils; /** * Renames a file. @@ -115,15 +117,15 @@ throw new BuildException(src attribute is required, getLocation()); } -if (replace dest.exists()) { -if (!dest.delete()) { -throw new BuildException(Unable to remove existing file + - dest); -} +if (!replace dest.exists()) { +throw new BuildException(dest + already exists.); } -if (!src.renameTo(dest)) { + +try { +FileUtils.newFileUtils().rename(src, dest); +} catch (IOException e) { throw new BuildException(Unable to rename + src + to + - dest); + dest, e, getLocation()); } } } 1.40 +1 -8 ant/src/main/org/apache/tools/ant/taskdefs/Replace.java Index: Replace.java === RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/Replace.java,v retrieving revision 1.39 retrieving revision 1.40 diff -u -r1.39 -r1.40 --- Replace.java 24 Apr 2003 09:27:02 - 1.39 +++ Replace.java 25 Jun 2003 11:52:46 - 1.40 @@ -445,14 +445,7 @@ // otherwise, delete the new one if (changes) { ++fileCount; -if (!src.delete()) { -throw new BuildException(Couldn't delete + src, - getLocation()); -} -if (!temp.renameTo(src)) { -throw new BuildException(Couldn't rename temporary file - + temp, getLocation()); -} +fileUtils.rename(temp, src); temp = null; } } catch (IOException ioe) { 1.107 +7 -5 ant/src/main/org/apache/tools/ant/taskdefs/Zip.java Index: Zip.java === RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/Zip.java,v retrieving revision 1.106 retrieving revision 1.107 diff -u -r1.106 -r1.107 --- Zip.java 2 May 2003 14:50:10 - 1.106 +++ Zip.java 25 Jun 2003 11:52:46 - 1.107 @@ -400,13 +400,13 @@ fileUtils.getParentFile(zipFile)); try { -if (!zipFile.renameTo(renamedFile)) { -throw new BuildException(Unable to rename old file - + to temporary file); -} +fileUtils.rename(zipFile, renamedFile); } catch (SecurityException e) { throw new BuildException(Not allowed to rename old file + to temporary file); +} catch (IOException e) { +throw new BuildException(Unable to rename old file + + to temporary file); } } @@ -498,7 +498,9 @@
cvs commit: ant/src/main/org/apache/tools/ant/taskdefs/optional/unix Symlink.java
bodewig 2003/03/26 07:50:28 Modified:src/main/org/apache/tools/ant/taskdefs/optional/unix Symlink.java Log: Fix javadocs. PR: 17143 Submitted by: Gus Heck Revision ChangesPath 1.4 +7 -7 ant/src/main/org/apache/tools/ant/taskdefs/optional/unix/Symlink.java Index: Symlink.java === RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/optional/unix/Symlink.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- Symlink.java 10 Feb 2003 14:14:28 - 1.3 +++ Symlink.java 26 Mar 2003 15:50:28 - 1.4 @@ -141,12 +141,12 @@ * absolute paths. On non-unix systems this may cause false positives. * Furthermore, any operating system on which the command * codeln -s link resource/code is not a valid command on the comandline - * will not be able to use action=single or action=multi action=record - * should still work. Finally, the lack of support for symlinks in Java - * means that all links are recorded as links to the - * strongcanonical/strong resource name. Therefore the link: - * codelink -- subdir/dir/../foo.bar/code will be recorded as - * codelink=subdir/foo.bar/code and restored as + * will not be able to use action= delete, action=single or + * action=recreate, but action=record should still work. Finally, the + * lack of support for symlinks in Java means that all links are recorded + * as links to the strongcanonical/strong resource name. Therefore + * the link: codelink -- subdir/dir/../foo.bar/code will be recorded + * as codelink=subdir/foo.bar/code and restored as * codelink -- subdir/foo.bar/code * * @version $Revision$