public class Get extends Task
Modifier and Type | Class and Description |
---|---|
protected static class |
Get.Base64Converter
Provide this for Backward Compatibility.
|
static interface |
Get.DownloadProgress
Interface implemented for reporting
progress of downloading.
|
static class |
Get.NullProgress
do nothing with progress info
|
static class |
Get.VerboseProgress
verbose progress system prints to some output stream
|
Constructor and Description |
---|
Get() |
Modifier and Type | Method and Description |
---|---|
void |
add(FileNameMapper fileNameMapper)
Add a nested filenamemapper.
|
void |
add(ResourceCollection rc)
Adds URLs to get.
|
Mapper |
createMapper()
Define the mapper to map source to destination files.
|
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 |
log(String msg,
int msgLevel)
Logs a message with the given priority.
|
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 |
setQuiet(boolean v)
If true, set default log level to Project.MSG_ERR.
|
void |
setRetries(int r)
The number of attempts to make for opening the URI, defaults to 3.
|
void |
setSkipExisting(boolean s)
Skip files that already exist locally.
|
void |
setSrc(URL u)
Set an URL to get.
|
void |
setTryGzipEncoding(boolean b)
Whether to transparently try to reduce bandwidth by telling the
server ant would support gzip encoding.
|
void |
setUserAgent(String userAgent)
HTTP connections only - set the user-agent to be used
when communicating with remote server.
|
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.
|
bindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType
clone, getDescription, getLocation, getProject, setDescription, setLocation, setProject
public void add(FileNameMapper fileNameMapper)
fileNameMapper
- the mapper to add.public void add(ResourceCollection rc)
public Mapper createMapper() throws BuildException
BuildException
- if more than one mapper is defined.public boolean doGet(URL source, File dest, int logLevel, Get.DownloadProgress progress) throws IOException
source
- the URL to getdest
- the target filelogLevel
- level to log at, see Project.log(String, int)
progress
- progress callback; null for no-callbacksignoreErrors
is true, as
when false all failures raise BuildExceptions.IOException
- for network troubleBuildException
- for argument errors, or other trouble when ignoreErrors
is false.public void execute() throws BuildException
execute
in class Task
BuildException
- Thrown in unrecoverable error.public void log(String msg, int msgLevel)
Task
public void setDest(File dest)
dest
- Path to file.public void setHttpUseCaches(boolean httpUseCache)
Defaults to true (allow caching, which is also the HttpUrlConnection default value.
public void setIgnoreErrors(boolean v)
v
- if "true" then don't report download errors up to antpublic void setMaxTime(long maxTime)
public void setPassword(String p)
p
- password for authenticationpublic void setQuiet(boolean v)
v
- if "true" then be quietpublic void setRetries(int r)
The name of the method is misleading as a value of 1 means "don't retry on error" and a value of 0 meant don't even try to reach the URI at all.
r
- number of attempts to makepublic void setSkipExisting(boolean s)
s
- "true" to skip existing destination filespublic void setSrc(URL u)
u
- URL for the file.public void setTryGzipEncoding(boolean b)
Setting this to true also means Ant will uncompress
.tar.gz
and similar files automatically.
public void setUserAgent(String userAgent)
public void setUsername(String u)
u
- username for authenticationpublic void setUseTimestamp(boolean v)
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.
v
- "true" to enable file time fetchingpublic void setVerbose(boolean v)
v
- if "true" then be verbose