public class Symlink extends DispatchTask
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.
description, location, project
Constructor and Description |
---|
Symlink() |
Modifier and Type | Method and Description |
---|---|
void |
addFileset(FileSet set)
Add a fileset to this task.
|
void |
delete()
Delete a symlink.
|
static void |
deleteSymlink(java.io.File linkfil)
Deprecated.
use
Files.delete(Path) instead |
static void |
deleteSymlink(java.lang.String path)
Deprecated.
use
Files.delete(Path) instead |
void |
execute()
The standard method for executing any task.
|
void |
init()
Initialize the task.
|
void |
record()
Record symlinks.
|
void |
recreate()
Restore symlinks.
|
void |
setAction(java.lang.String action)
Set the action to be performed.
|
void |
setFailOnError(boolean foe)
Set failonerror mode.
|
void |
setLink(java.lang.String lnk)
Set the name of the link.
|
void |
setLinkfilename(java.lang.String lf)
Set the name of the file to which links will be written.
|
void |
setOverwrite(boolean owrite)
Set overwrite mode.
|
void |
setResource(java.lang.String src)
Set the name of the resource to which a link should be created.
|
void |
single()
Create a symlink.
|
getAction, getActionParameterName
bindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, isInvalid, log, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType
clone, getDescription, getLocation, getProject, setDescription, setLocation, setProject
public void init() throws BuildException
init
in class Task
BuildException
- on error.public void execute() throws BuildException
execute
in class Task
BuildException
- on error.public void single() throws BuildException
BuildException
- on error.public void delete() throws BuildException
BuildException
- on error.public void recreate() throws BuildException
BuildException
- on error.public void record() throws BuildException
BuildException
- on error.public void setOverwrite(boolean owrite)
owrite
- If true overwrite existing links.public void setFailOnError(boolean foe)
foe
- If true throw BuildException on error, else log it.public void setAction(java.lang.String action)
setAction
in class DispatchTask
action
- The action to perform.public void setLink(java.lang.String lnk)
lnk
- The name for the link.public void setResource(java.lang.String src)
src
- The resource to be linked.public void setLinkfilename(java.lang.String lf)
lf
- The name of the file to write links to.public void addFileset(FileSet set)
set
- The fileset to add.@Deprecated public static void deleteSymlink(java.lang.String path) throws java.io.IOException
Files.delete(Path)
insteadThis is a convenience method that simply invokes deleteSymlink(File)
path
- A string containing the path of the symlink to delete.java.io.IOException
- If the deletion attempt fails@Deprecated public static void deleteSymlink(java.io.File linkfil) throws java.io.IOException
Files.delete(Path)
insteadThis 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 Files.isSymbolicLink(Path)
and Files.delete(Path)
to check and delete the symlink
linkfil
- A File
object of the symlink to delete. Cannot be null.java.io.IOException
- If the attempt to delete runs into exception