|
@@ -66,29 +66,31 @@ import org.apache.tools.ant.taskdefs.Execute; |
|
|
* |
|
|
* |
|
|
* <p> Examples of use: |
|
|
* <p> Examples of use: |
|
|
* |
|
|
* |
|
|
* <p> Make a link named "foo" to a resource named "bar.foo" in subdir: |
|
|
|
|
|
|
|
|
* <p> Make a link named "foo" to a resource named |
|
|
|
|
|
* "bar.foo" in subdir: |
|
|
* <pre> |
|
|
* <pre> |
|
|
* <symlink link="${dir.top}/foo" resource="${dir.top}/subdir/bar.foo"/> |
|
|
|
|
|
|
|
|
* <symlink link="${dir.top}/foo" resource="${dir.top}/subdir/bar.foo"/> |
|
|
* </pre> |
|
|
* </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 |
|
|
|
|
|
* "dir.links" |
|
|
* <pre> |
|
|
* <pre> |
|
|
* <symlink action="record" linkfilename="dir.links"> |
|
|
|
|
|
* <fileset dir="${dir.top}" includes="subdir/**" /> |
|
|
|
|
|
|
|
|
* <symlink action="record" linkfilename="dir.links"> |
|
|
|
|
|
* <fileset dir="${dir.top}" includes="subdir/**" /> |
|
|
* </symlink> |
|
|
* </symlink> |
|
|
* </pre> |
|
|
* </pre> |
|
|
* |
|
|
* |
|
|
* <p> Recreate the links recorded in the previous example: |
|
|
* <p> Recreate the links recorded in the previous example: |
|
|
* <pre> |
|
|
* <pre> |
|
|
* <symlink action="recreate"> |
|
|
|
|
|
* <fileset dir="${dir.top}" includes="subdir/**/dir.links" /> |
|
|
|
|
|
|
|
|
* <symlink action="recreate"> |
|
|
|
|
|
* <fileset dir="${dir.top}" includes="subdir/**/dir.links" /> |
|
|
* </symlink> |
|
|
* </symlink> |
|
|
* </pre> |
|
|
* </pre> |
|
|
* |
|
|
* |
|
|
* <p> Delete a link named "foo" to a resource named "bar.foo" in subdir: |
|
|
|
|
|
|
|
|
* <p> Delete a link named "foo" to a resource named |
|
|
|
|
|
* "bar.foo" in subdir: |
|
|
* <pre> |
|
|
* <pre> |
|
|
* <symlink action="delete" link="${dir.top}/foo"/> |
|
|
|
|
|
|
|
|
* <symlink action="delete" link="${dir.top}/foo"/> |
|
|
* </pre> |
|
|
* </pre> |
|
|
* |
|
|
* |
|
|
* <p><strong>LIMITATIONS:</strong> Because Java has no direct support for |
|
|
* <p><strong>LIMITATIONS:</strong> Because Java has no direct support for |
|
@@ -96,17 +98,16 @@ import org.apache.tools.ant.taskdefs.Execute; |
|
|
* absolute paths. On non-unix systems this may cause false positives. |
|
|
* absolute paths. On non-unix systems this may cause false positives. |
|
|
* Furthermore, any operating system on which the command |
|
|
* Furthermore, any operating system on which the command |
|
|
* <code>ln -s link resource</code> is not a valid command on the command line |
|
|
* <code>ln -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 <strong>canonical</strong> resource name. Therefore |
|
|
|
|
|
* the link: <code>link --> subdir/dir/../foo.bar</code> will be recorded |
|
|
|
|
|
* as <code>link=subdir/foo.bar</code> and restored as |
|
|
|
|
|
* <code>link --> subdir/foo.bar</code> |
|
|
|
|
|
|
|
|
* 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 <strong>canonical</strong> resource name. |
|
|
|
|
|
* Therefore the link: <code>link --> subdir/dir/../foo.bar</code> will be |
|
|
|
|
|
* recorded as <code>link=subdir/foo.bar</code> and restored as |
|
|
|
|
|
* <code>link --> subdir/foo.bar</code>. |
|
|
* |
|
|
* |
|
|
* @version $Revision$ |
|
|
* @version $Revision$ |
|
|
*/ |
|
|
*/ |
|
|
|
|
|
|
|
|
public class Symlink extends Task { |
|
|
public class Symlink extends Task { |
|
|
|
|
|
|
|
|
// Attributes with setter methods: |
|
|
// Attributes with setter methods: |
|
@@ -120,8 +121,10 @@ public class Symlink extends Task { |
|
|
|
|
|
|
|
|
private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); |
|
|
private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); |
|
|
|
|
|
|
|
|
/** Initialize the task. */ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* Initialize the task. |
|
|
|
|
|
* @throws BuildException on error. |
|
|
|
|
|
*/ |
|
|
public void init() throws BuildException { |
|
|
public void init() throws BuildException { |
|
|
super.init(); |
|
|
super.init(); |
|
|
failonerror = true; // default behavior is to fail on an error |
|
|
failonerror = true; // default behavior is to fail on an error |
|
@@ -285,17 +288,18 @@ public class Symlink extends Task { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* The setter for the "action" attribute. May be "single", "multi" |
|
|
|
|
|
* or "record" |
|
|
|
|
|
|
|
|
* Set the action to be performed. May be |
|
|
|
|
|
* "single", "multi" or "record". |
|
|
* |
|
|
* |
|
|
* @param typ The action of action to perform. |
|
|
|
|
|
|
|
|
* @param typ The action to perform. |
|
|
*/ |
|
|
*/ |
|
|
public void setAction(String typ) { |
|
|
public void setAction(String typ) { |
|
|
this.action = 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 = "single". |
|
|
* |
|
|
* |
|
|
* @param lnk The name for the link. |
|
|
* @param lnk The name for the link. |
|
|
*/ |
|
|
*/ |
|
@@ -304,16 +308,18 @@ public class Symlink extends Task { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 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 action = "single". |
|
|
* |
|
|
* |
|
|
* @param src The source of the resource to be linked. |
|
|
|
|
|
|
|
|
* @param src The resource to be linked. |
|
|
*/ |
|
|
*/ |
|
|
public void setResource(String src) { |
|
|
public void setResource(String src) { |
|
|
this.resource = src; |
|
|
this.resource = src; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* The setter for the "linkfilename" attribute. Only used for action=record. |
|
|
|
|
|
|
|
|
* Set the name of the file to which links will be written. |
|
|
|
|
|
* Only used when action = "record". |
|
|
* |
|
|
* |
|
|
* @param lf The name of the file to write links to. |
|
|
* @param lf The name of the file to write links to. |
|
|
*/ |
|
|
*/ |
|
@@ -322,7 +328,7 @@ public class Symlink extends Task { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Adds a fileset to this task. |
|
|
|
|
|
|
|
|
* Add a fileset to this task. |
|
|
* |
|
|
* |
|
|
* @param set The fileset to add. |
|
|
* @param set The fileset to add. |
|
|
*/ |
|
|
*/ |
|
@@ -335,7 +341,7 @@ public class Symlink extends Task { |
|
|
* ********************************************************** */ |
|
|
* ********************************************************** */ |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Deletes a symlink without deleteing the resource it points to. |
|
|
|
|
|
|
|
|
* Deletes a symlink without deleting the resource it points to. |
|
|
* |
|
|
* |
|
|
* <p>This is a convenience method that simply invokes |
|
|
* <p>This is a convenience method that simply invokes |
|
|
* <code>deleteSymlink(java.io.File)</code>. |
|
|
* <code>deleteSymlink(java.io.File)</code>. |
|
@@ -427,8 +433,6 @@ public class Symlink extends Task { |
|
|
* This method use <code>Properties.store</code> |
|
|
* This method use <code>Properties.store</code> |
|
|
* and thus report exceptions that occur while writing the file. |
|
|
* and thus report exceptions that occur while writing the file. |
|
|
* |
|
|
* |
|
|
* This is not jdk 1.1 compatible, but Ant 1.6 is not anymore. |
|
|
|
|
|
* |
|
|
|
|
|
* @param properties The properties object to be written. |
|
|
* @param properties The properties object to be written. |
|
|
* @param propertyfile The File to write to. |
|
|
* @param propertyfile The File to write to. |
|
|
* @param comment The comment to place at the head of the file. |
|
|
* @param comment The comment to place at the head of the file. |
|
@@ -443,7 +447,6 @@ public class Symlink extends Task { |
|
|
try { |
|
|
try { |
|
|
fos = new FileOutputStream(propertyfile); |
|
|
fos = new FileOutputStream(propertyfile); |
|
|
properties.store(fos, comment); |
|
|
properties.store(fos, comment); |
|
|
|
|
|
|
|
|
} catch (IOException ioe) { |
|
|
} catch (IOException ioe) { |
|
|
throw new BuildException(ioe, getLocation()); |
|
|
throw new BuildException(ioe, getLocation()); |
|
|
} finally { |
|
|
} finally { |
|
@@ -528,11 +531,11 @@ public class Symlink extends Task { |
|
|
/** |
|
|
/** |
|
|
* Finds all the links in all supplied filesets. |
|
|
* Finds all the links in all supplied filesets. |
|
|
* |
|
|
* |
|
|
* <p> This method is invoked when the action attribute is is "record". |
|
|
|
|
|
* This means that filesets are interpreted as the directories in |
|
|
|
|
|
* which links may be found. |
|
|
|
|
|
|
|
|
* <p> This method is invoked when the action attribute is |
|
|
|
|
|
* "record". This means that filesets are interpreted |
|
|
|
|
|
* as the directories in which links may be found. |
|
|
* |
|
|
* |
|
|
* <p> The basic method follwed here is, for each file set: |
|
|
|
|
|
|
|
|
* <p> The basic method followed here is, for each fileset: |
|
|
* <ol> |
|
|
* <ol> |
|
|
* <li> Compile a list of all matches </li> |
|
|
* <li> Compile a list of all matches </li> |
|
|
* <li> Convert matches to <code>File</code> objects </li> |
|
|
* <li> Convert matches to <code>File</code> objects </li> |
|
@@ -545,7 +548,7 @@ public class Symlink extends Task { |
|
|
* </ol> |
|
|
* </ol> |
|
|
* |
|
|
* |
|
|
* @param fileSets The filesets specified by the user. |
|
|
* @param fileSets The filesets specified by the user. |
|
|
* @return A vector of <code>File</code> objects containing the |
|
|
|
|
|
|
|
|
* @return A Vector of <code>File</code> objects containing the |
|
|
* links (with canonical parent directories). |
|
|
* links (with canonical parent directories). |
|
|
*/ |
|
|
*/ |
|
|
|
|
|
|
|
@@ -647,8 +650,8 @@ public class Symlink extends Task { |
|
|
* Load the links from a properties file. |
|
|
* Load the links from a properties file. |
|
|
* |
|
|
* |
|
|
* <p> This method is only invoked when the action attribute is set to |
|
|
* <p> This method is only invoked when the action attribute is set to |
|
|
* "multi". The filesets passed in are assumed to specify the names |
|
|
|
|
|
* of the property files with the link information and the |
|
|
|
|
|
|
|
|
* "multi". The filesets passed in are assumed to specify the |
|
|
|
|
|
* names of the property files with the link information and the |
|
|
* subdirectories in which to look for them. |
|
|
* subdirectories in which to look for them. |
|
|
* |
|
|
* |
|
|
* <p> The basic method follwed here is, for each file set: |
|
|
* <p> The basic method follwed here is, for each file set: |
|
|