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 (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 associated resource.
Usage examples:
Make a link named "foo" to a resource named "bar.foo" in subdir:
<symlink link="${dir.top}/foo" resource="${dir.top}/subdir/bar.foo"/>
Record all links in subdir and its descendants in files named "dir.links":
<symlink action="record" linkfilename="dir.links">
<fileset dir="${dir.top}" includes="subdir/**" />
</symlink>
Recreate the links recorded in the previous example:
<symlink action="recreate">
<fileset dir="${dir.top}" includes="subdir/**/dir.links" />
</symlink>
Delete a link named "foo" to a resource named "bar.foo" in subdir:
<symlink action="delete" link="${dir.top}/foo"/>
Note
Starting Ant version 1.10.2, this task relies on the symbolic link support
introduced in Java 7 through the Files APIs.
| Modifier and Type | Field and Description |
|---|---|
| private boolean | |
| private boolean | |
| private List | |
| private String | |
| private String | |
| private boolean | |
| private String |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| public void | |
| public static void | deleteSymlink(final String
A string containing the path of the symlink to delete. path)
Deprecated
use
Delete a symlink (without deleting the associated resource).
Files#delete(Path) instead
|
| public static void | deleteSymlink(final File
A linkfil)File object of the symlink to delete. Cannot be null.
Deprecated
use
Delete a symlink (without deleting the associated resource).
Files#delete(Path) instead
|
| private static void | |
| private void | |
| public synchronized void | |
| private Set | |
| private void | handleError(String
The message to log, or include in the
msg)BuildException.Handle errors based on the setting of failonerror. |
| public void | |
| private Properties | |
| public void | |
| public void | |
| public void | setAction(String
The action to perform. action)Overrides org. |
| private void | |
| public void | |
| public void | |
| public void | setLinkfilename(String
The name of the file to write links to. lf)Set the name of the file to which links will be written. |
| public void | |
| public void | setResource(String
The resource to be linked. src)Set the name of the resource to which a link should be created. |
| public void | |
| private void | writePropertyFile(Properties
The properties object to be written. properties, File The directory for which we are writing the links. dir)Write a properties file. |
| executing | back to summary |
|---|---|
| private boolean executing | |
| failonerror | back to summary |
|---|---|
| private boolean failonerror | |
| fileSets | back to summary |
|---|---|
| private List<FileSet> fileSets | |
| link | back to summary |
|---|---|
| private String link | |
| linkFileName | back to summary |
|---|---|
| private String linkFileName | |
| overwrite | back to summary |
|---|---|
| private boolean overwrite | |
| resource | back to summary |
|---|---|
| private String resource | |
| Symlink | back to summary |
|---|---|
| public Symlink() | |
| addFileset | back to summary |
|---|---|
| public void addFileset(FileSet set) Add a fileset to this task.
| |
| delete | back to summary |
|---|---|
| public void delete() throws BuildException Delete a symlink.
| |
| deleteSymlink | back to summary |
|---|---|
| public static void deleteSymlink(final String path) throws IOException
Deprecated use Delete a symlink (without deleting the associated resource). This is a convenience method that simply invokes
| |
| deleteSymlink | back to summary |
|---|---|
| public static void deleteSymlink(final File linkfil) throws IOException
Deprecated use Delete a symlink (without deleting the associated resource). This is a utility method that removes a symlink without removing the resource that the symlink points to. If it is accidentally invoked on a real file, the real file will not be harmed and instead this method returns silently. Since Ant 1.10.2 this method relies on the
| |
| deleteSymLink | back to summary |
|---|---|
| private static void deleteSymLink(final Path path) throws IOException | |
| doLink | back to summary |
|---|---|
| private void doLink(String resource, String link) throws BuildException Conduct the actual construction of a link.
| |
| execute | back to summary |
|---|---|
| public synchronized void execute() throws BuildException Overrides org. The standard method for executing any task.
| |
| findLinks | back to summary |
|---|---|
| private Set Find all the links in all supplied filesets. 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. | |
| handleError | back to summary |
|---|---|
| private void handleError(String msg) Handle errors based on the setting of failonerror.
| |
| init | back to summary |
|---|---|
| public void init() throws BuildException Overrides org. Initialize the task.
| |
| loadLinks | back to summary |
|---|---|
| private Properties loadLinks(List<FileSet> fileSets) Load links from properties files included in one or more FileSets. This method is only invoked when the action attribute is set to "recreate". 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.
| |
| record | back to summary |
|---|---|
| public void record() throws BuildException Record symlinks.
| |
| recreate | back to summary |
|---|---|
| public void recreate() throws BuildException Restore symlinks.
| |
| setAction | back to summary |
|---|---|
| public void setAction(String action) Overrides org. Set the action to be performed. May be "single", "delete", "recreate" or "record". | |
| setDefaults | back to summary |
|---|---|
| private void setDefaults() Return all variables to their default state for the next invocation.
| |
| setFailOnError | back to summary |
|---|---|
| public void setFailOnError(boolean foe) Set failonerror mode. If set to true (default) the entire build fails upon error; otherwise the error is logged and the build will continue.
| |
| setLink | back to summary |
|---|---|
| public void setLink(String link) Set the name of the link. Used when action = "single".
| |
| setLinkfilename | back to summary |
|---|---|
| public void setLinkfilename(String lf) Set the name of the file to which links will be written. Used when action = "record".
| |
| setOverwrite | back to summary |
|---|---|
| public void setOverwrite(boolean owrite) Set overwrite mode. If set to false (default) the task will not overwrite existing links, and may stop the build if a link already exists depending on the setting of failonerror.
| |
| setResource | back to summary |
|---|---|
| public void setResource(String src) Set the name of the resource to which a link should be created. Used when action = "single".
| |
| single | back to summary |
|---|---|
| public void single() throws BuildException Create a symlink.
| |
| writePropertyFile | back to summary |
|---|---|
| private void writePropertyFile(Properties properties, File dir) throws BuildException Write a properties file. This method uses
| |