public class GetWild extends org.apache.tools.ant.Task
Normally, this task is used with files whose names contain a variable portion, the matching of which allows '*' wildcarding.
Requires the jakarta commons-net jar (for FTP).
If the task's name is set and multiple matching is not enabled, five project properties are set:<taskname>
is set to the destination file's full path.<taskname>.name
is set to the destination file's name.<taskname>.basename
is set to the destination file's name minus the last '.extenstion'.<taskname>.baseURL
is set to the URL of the source file's parent directory.<taskname>.wildcard
is set to the portion of the URL corresponding to the first '*'.Attribute | Description | Required |
name | The name (handle) of the property. | No |
src | The URL (http, ftp, or a file system path) of the remote file (may contain one or more '*' wildcards). | Yes |
dest | The local file to copy into. | Yes |
destdir | The local directory to copy into. The file's remote name is maintained. | |
matchmultiple | Used with destdir, retrieves all matching files and no properties are set. If false, only the most recent matching file is retrieved and properties are set. (false by default) | No |
ignoreerrors | Do not halt ant execution on failure. (false by default) | No |
usetimestamp | Use the file's timestamp and size to determine if freshening the local copy is necessary. (true by default) | No |
if | Only execute if a property of the given name exists in the current project. | No |
unless | Only execute if a property of the given name doesn't exist in the current project. | No |
useragent | User-Agent HTTP header to send, Ant will specify a User-Agent header of "Apache Ant VERSION" unless overridden by this attribute. | No |
The if
and unless
attributes make the
execution conditional -both probe for the named property being defined.
The if
tests for the property being defined, the
unless
for a property being undefined.
execute := defined(ifProperty) && !defined(unlessProperty)The following example downloads the most recent file matching the src pattern to the specified local destination:
<getwild name='ij' src='http://rsb.info.nih.gov/ij/download/zips/ij*.zip' dest='${tmp.dir}/ij.zip' />
Constructor and Description |
---|
GetWild() |
Modifier and Type | Method and Description |
---|---|
void |
execute()
Does the work.
|
void |
setDest(File inValue)
Specifies where to copy the source file.
|
void |
setDestdir(File inValue)
Specifies the local directory to copy the remote file into
(preserving the file's remote name).
|
void |
setIf(String inPropertyName)
Only execute if a property of the given name exists in the current project.
|
void |
setIgnoreErrors(boolean inValue)
Specifies whether or not to ignore retrieval errors.
|
void |
setMatchMultiple(boolean inValue)
Specifies whether or not to retrieve multiple matching files.
|
void |
setName(String name)
Set the task's name.
|
void |
setSrc(String inURL)
The remote file for retrieval.
|
void |
setUnless(String inPropertyName)
Only execute if a property of the given name does not exist in the current project.
|
void |
setUserAgent(String inValue)
User-Agent HTTP header to send, Ant will specify a User-Agent header of "Apache Ant VERSION" unless overridden by this attribute.
|
void |
setUseTimestamp(boolean inValue)
If set to true, the remote file's timestamp will be compared
to the local file (if present) before downloading.
|
bindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType
public GetWild()
public void setSrc(String inURL)
inURL
- the remote file for retrievalpublic void setDest(File inValue)
inValue
- the local file to copy the remote file topublic void setDestdir(File inValue)
inValue
- the local directory to copy the remote file intopublic void setIf(String inPropertyName)
inPropertyName
- property namepublic void setUnless(String inPropertyName)
inPropertyName
- property namepublic void setMatchMultiple(boolean inValue)
inValue
- whether or not to retrieve multiple matching filespublic void setIgnoreErrors(boolean inValue)
inValue
- whether or not to ignore retrieval errorspublic void setUseTimestamp(boolean inValue)
inValue
- whether or not to compare the remote timestamp to the local filepublic void setUserAgent(String inValue)
inValue
- the value to use for the User-Agent header field in HTTP requestspublic void execute() throws org.apache.tools.ant.BuildException
execute
in class org.apache.tools.ant.Task
org.apache.tools.ant.BuildException
- Thrown in unrecoverable error.
jataylor@hairyfatguy.com