org.apache.tools.ant.taskdefs
public class Get extends Task
Since: Ant 1.1
UNKNOWN: category="network"
Nested Class Summary | |
---|---|
protected static class | Get.Base64Converter
Provide this for Backward Compatibility. |
interface | Get.DownloadProgress
Interface implemented for reporting
progess of downloading. |
static class | Get.NullProgress
do nothing with progress info |
static class | Get.VerboseProgress
verbose progress system prints to some output stream |
Method Summary | |
---|---|
void | add(ResourceCollection rc)
Adds URLs to get. |
void | add(FileNameMapper fileNameMapper)
Add a nested filenamemapper. |
Mapper | createMapper()
Define the mapper to map source to destination files. |
boolean | doGet(int logLevel, Get.DownloadProgress progress)
make a get request, with the supplied progress and logging info.
|
boolean | doGet(URL source, File dest, int logLevel, Get.DownloadProgress progress)
make a get request, with the supplied progress and logging info.
|
void | execute()
Does the work.
|
void | setDest(File dest)
Where to copy the source file.
|
void | setHttpUseCaches(boolean httpUseCache)
HTTP connections only - control caching on the
HttpUrlConnection: httpConnection.setUseCaches(); if false, do
not allow caching on the HttpUrlConnection.
|
void | setIgnoreErrors(boolean v)
If true, log errors but do not treat as fatal.
|
void | setMaxTime(long maxTime)
The time in seconds the download is allowed to take before
being terminated.
|
void | setPassword(String p)
password for the basic authentication.
|
void | setRetries(int r)
The number of retries to attempt upon error, defaults to 3.
|
void | setSkipExisting(boolean s)
Skip files that already exist locally.
|
void | setSrc(URL u)
Set an URL to get.
|
void | setUsername(String u)
Username for basic auth.
|
void | setUseTimestamp(boolean v)
If true, conditionally download a file based on the timestamp
of the local copy.
|
void | setVerbose(boolean v)
If true, show verbose progress information.
|
Since: Ant 1.8.0
Parameters: fileNameMapper the mapper to add.
Since: Ant 1.8.0
Returns: a mapper to be configured.
Throws: BuildException if more than one mapper is defined.
Since: Ant 1.8.0
Deprecated: only gets the first configured resource
make a get request, with the supplied progress and logging info. All the other config parameters are set at the task level, source, dest, ignoreErrors, etc.Parameters: logLevel level to log at, see Project progress progress callback; null for no-callbacks
Returns: true for a successful download, false otherwise. The return value is only relevant when ignoreErrors is true, as when false all failures raise BuildExceptions.
Throws: IOException for network trouble BuildException for argument errors, or other trouble when ignoreErrors is false.
Parameters: source the URL to get dest the target file logLevel level to log at, see Project progress progress callback; null for no-callbacks
Returns: true for a successful download, false otherwise. The return value is only relevant when ignoreErrors is true, as when false all failures raise BuildExceptions.
Throws: IOException for network trouble BuildException for argument errors, or other trouble when ignoreErrors is false.
Since: Ant 1.8.0
Throws: BuildException Thrown in unrecoverable error.
Parameters: dest Path to file.
Defaults to true (allow caching, which is also the HttpUrlConnection default value.
Since: Ant 1.8.0
Parameters: v if "true" then don't report download errors up to ant
Since: Ant 1.8.0
Parameters: p password for authentication
Parameters: r retry count
Since: Ant 1.8.0
Parameters: s "true" to skip existing destination files
Since: Ant 1.8.0
Parameters: u URL for the file.
Parameters: u username for authentication
In this situation, the if-modified-since header is set so that the file is only fetched if it is newer than the local file (or there is no local file) This flag is only valid on HTTP connections, it is ignored in other cases. When the flag is set, the local copy of the downloaded file will also have its timestamp set to the remote file time.
Note that remote files of date 1/1/1970 (GMT) are treated as 'no timestamp', and web servers often serve files with a timestamp in the future by replacing their timestamp with that of the current time. Also, inter-computer clock differences can cause no end of grief.
Parameters: v "true" to enable file time fetching
Parameters: v if "true" then be verbose