Class Symlink
- java.lang.Object
- 
- org.apache.tools.ant.ProjectComponent
- 
- org.apache.tools.ant.Task
- 
- org.apache.tools.ant.dispatch.DispatchTask
- 
- org.apache.tools.ant.taskdefs.optional.unix.Symlink
 
 
 
 
- 
- All Implemented Interfaces:
- java.lang.Cloneable,- Dispatchable
 
 public class Symlink extends DispatchTask Creates, Deletes, Records and Restores Symlinks.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 FilesAPIs.
- 
- 
Field Summary- 
Fields inherited from class org.apache.tools.ant.ProjectComponentdescription, location, project
 
- 
 - 
Constructor SummaryConstructors Constructor Description Symlink()
 - 
Method SummaryModifier and Type Method Description voidaddFileset(FileSet set)Add a fileset to this task.voiddelete()Delete a symlink.static voiddeleteSymlink(java.io.File linkfil)Deprecated.useFiles.delete(Path)insteadstatic voiddeleteSymlink(java.lang.String path)Deprecated.useFiles.delete(Path)insteadvoidexecute()The standard method for executing any task.voidinit()Initialize the task.voidrecord()Record symlinks.voidrecreate()Restore symlinks.voidsetAction(java.lang.String action)Set the action to be performed.voidsetFailOnError(boolean foe)Set failonerror mode.voidsetLink(java.lang.String lnk)Set the name of the link.voidsetLinkfilename(java.lang.String lf)Set the name of the file to which links will be written.voidsetOverwrite(boolean owrite)Set overwrite mode.voidsetResource(java.lang.String src)Set the name of the resource to which a link should be created.voidsingle()Create a symlink.- 
Methods inherited from class org.apache.tools.ant.dispatch.DispatchTaskgetAction, getActionParameterName
 - 
Methods inherited from class org.apache.tools.ant.TaskbindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, isInvalid, log, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType
 - 
Methods inherited from class org.apache.tools.ant.ProjectComponentclone, getDescription, getLocation, getProject, setDescription, setLocation, setProject
 
- 
 
- 
- 
- 
Method Detail- 
initpublic void init() throws BuildExceptionInitialize the task.- Overrides:
- initin class- Task
- Throws:
- BuildException- on error.
 
 - 
executepublic void execute() throws BuildExceptionThe standard method for executing any task.- Overrides:
- executein class- Task
- Throws:
- BuildException- on error.
 
 - 
singlepublic void single() throws BuildExceptionCreate a symlink.- Throws:
- BuildException- on error.
- Since:
- Ant 1.7
 
 - 
deletepublic void delete() throws BuildExceptionDelete a symlink.- Throws:
- BuildException- on error.
- Since:
- Ant 1.7
 
 - 
recreatepublic void recreate() throws BuildExceptionRestore symlinks.- Throws:
- BuildException- on error.
- Since:
- Ant 1.7
 
 - 
recordpublic void record() throws BuildExceptionRecord symlinks.- Throws:
- BuildException- on error.
- Since:
- Ant 1.7
 
 - 
setOverwritepublic 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.- Parameters:
- owrite- If true overwrite existing links.
 
 - 
setFailOnErrorpublic 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.- Parameters:
- foe- If true throw BuildException on error, else log it.
 
 - 
setActionpublic void setAction(java.lang.String action) Set the action to be performed. May be "single", "delete", "recreate" or "record".- Overrides:
- setActionin class- DispatchTask
- Parameters:
- action- The action to perform.
 
 - 
setLinkpublic void setLink(java.lang.String lnk) Set the name of the link. Used when action = "single".- Parameters:
- lnk- The name for the link.
 
 - 
setResourcepublic void setResource(java.lang.String src) Set the name of the resource to which a link should be created. Used when action = "single".- Parameters:
- src- The resource to be linked.
 
 - 
setLinkfilenamepublic void setLinkfilename(java.lang.String lf) Set the name of the file to which links will be written. Used when action = "record".- Parameters:
- lf- The name of the file to write links to.
 
 - 
addFilesetpublic void addFileset(FileSet set) Add a fileset to this task.- Parameters:
- set- The fileset to add.
 
 - 
deleteSymlink@Deprecated public static void deleteSymlink(java.lang.String path) throws java.io.IOExceptionDeprecated.useFiles.delete(Path)insteadDelete a symlink (without deleting the associated resource).This is a convenience method that simply invokes deleteSymlink(File)- Parameters:
- path- A string containing the path of the symlink to delete.
- Throws:
- java.io.IOException- If the deletion attempt fails
 
 - 
deleteSymlink@Deprecated public static void deleteSymlink(java.io.File linkfil) throws java.io.IOExceptionDeprecated.useFiles.delete(Path)insteadDelete 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 Files.isSymbolicLink(Path)andFiles.delete(Path)to check and delete the symlink- Parameters:
- linkfil- A- Fileobject of the symlink to delete. Cannot be null.
- Throws:
- java.io.IOException- If the attempt to delete runs into exception
 
 
- 
 
-