public class Download extends org.gradle.api.DefaultTask implements DownloadSpec
task downloadFile(type: Download) {
src 'http://www.example.com/file.ext'
dest buildDir
}
| Constructor and Description |
|---|
Download()
Default constructor
|
| Modifier and Type | Method and Description |
|---|---|
void |
acceptAnyCertificate(boolean accept)
Specifies if HTTPS certificate verification errors should be ignored
and any certificate (even an invalid one) should be accepted.
|
void |
authScheme(java.lang.String authScheme)
Sets the authentication scheme to use.
|
void |
cachedETagsFile(java.lang.Object location)
Sets the location of the file that keeps entity tags (ETags) received
from the server
|
void |
compress(boolean compress)
Specifies if compression should be used during download
|
void |
connectTimeout(int milliseconds)
Specifies the maximum time to wait in milliseconds until a connection is
established.
|
void |
dest(java.lang.Object dest)
Sets the download destination
|
void |
download()
Starts downloading
|
void |
downloadTaskDir(java.lang.Object dir)
Specifies the directory where gradle-download-task stores information
that should persist between builds
|
java.lang.String |
getAuthScheme() |
java.io.File |
getCachedETagsFile() |
int |
getConnectTimeout() |
java.io.File |
getDest() |
java.io.File |
getDownloadTaskDir() |
java.lang.String |
getHeader(java.lang.String name) |
java.util.Map<java.lang.String,java.lang.String> |
getHeaders() |
java.util.List<java.io.File> |
getOutputFiles() |
java.lang.String |
getPassword() |
int |
getReadTimeout() |
int |
getRetries() |
java.lang.Object |
getSrc() |
java.lang.Object |
getUseETag() |
java.lang.String |
getUsername() |
void |
header(java.lang.String name,
java.lang.String value)
Sets an HTTP request header to use when downloading
|
void |
headers(java.util.Map<java.lang.String,java.lang.String> headers)
Sets the HTTP request headers to use when downloading
|
boolean |
isAcceptAnyCertificate() |
boolean |
isCompress() |
boolean |
isOnlyIfModified() |
boolean |
isOnlyIfNewer()
Get the
onlyIfNewer flag. |
boolean |
isOverwrite() |
boolean |
isQuiet() |
boolean |
isTempAndMove() |
void |
onlyIfModified(boolean onlyIfModified)
Sets the onlyIfModified flag
|
void |
onlyIfNewer(boolean onlyIfNewer)
Sets the onlyIfNewer flag.
|
void |
overwrite(boolean overwrite)
Sets the overwrite flag
|
void |
password(java.lang.String password)
Sets the password for
Basic or Digest
authentication |
void |
quiet(boolean quiet)
Sets the quiet flag
|
void |
readTimeout(int milliseconds)
Specifies the maximum time in milliseconds to wait for data from the
server.
|
void |
retries(int retries)
Specifies the maximum number of retry attempts if a request has failed.
|
void |
src(java.lang.Object src)
Sets the download source URL
|
void |
tempAndMove(boolean tempAndMove)
Specifies whether the file should be downloaded to a temporary location
and, upon successful execution, moved to the final location.
|
void |
useETag(java.lang.Object useETag)
Sets the
useETag flag. |
void |
username(java.lang.String username)
Sets the username for
Basic or Digest
authentication |
newInputDirectory, newInputFile, newOutputDirectory, newOutputFileaddValidator, appendParallelSafeAction, compareTo, configure, deleteAllActions, dependsOn, dependsOnTaskDidWork, doFirst, doFirst, doFirst, doLast, doLast, doLast, execute, finalizedBy, getActions, getAnt, getAsDynamicObject, getConvention, getDependsOn, getDescription, getDestroyables, getDidWork, getEnabled, getExecuter, getExtensions, getFinalizedBy, getGroup, getIdentityPath, getImpliesSubProjects, getInputs, getLocalState, getLogger, getLogging, getMustRunAfter, getName, getOnlyIf, getOutputs, getPath, getProject, getServices, getShouldRunAfter, getStandardOutputCapture, getState, getTaskActions, getTaskDependencies, getTaskIdentity, getTemporaryDir, getTemporaryDirFactory, getValidators, hasProperty, hasTaskActions, injectIntoNewInstance, isEnabled, isHasCustomActions, leftShift, mustRunAfter, onlyIf, onlyIf, prependParallelSafeAction, property, replaceLogger, setActions, setDependsOn, setDescription, setDidWork, setEnabled, setExecuter, setFinalizedBy, setGroup, setImpliesSubProjects, setMustRunAfter, setOnlyIf, setOnlyIf, setProperty, setShouldRunAfter, shouldRunAfter, toStringpublic void download()
throws java.io.IOException
java.io.IOException - if the file could not downloaded@OutputFiles public java.util.List<java.io.File> getOutputFiles()
public void src(java.lang.Object src)
DownloadSpecsrc in interface DownloadSpecsrc - the URLpublic void dest(java.lang.Object dest)
DownloadSpecdest in interface DownloadSpecdest - a file or directory where to store the retrieved filepublic void quiet(boolean quiet)
DownloadSpecquiet in interface DownloadSpecquiet - true if download progress should not be loggedpublic void overwrite(boolean overwrite)
DownloadSpecoverwrite in interface DownloadSpecoverwrite - true if existing files should be overwritten, false otherwisepublic void onlyIfModified(boolean onlyIfModified)
DownloadSpeconlyIfModified in interface DownloadSpeconlyIfModified - true if the file should only be downloaded if it
has been modified on the server since the last downloadpublic void onlyIfNewer(boolean onlyIfNewer)
DownloadSpecDownloadSpec.onlyIfModified(boolean).onlyIfNewer in interface DownloadSpeconlyIfNewer - true if the file should only be downloaded if it
has been modified on the server since the last downloadpublic void compress(boolean compress)
DownloadSpeccompress in interface DownloadSpeccompress - true if compression should be enabledpublic void username(java.lang.String username)
DownloadSpecBasic or Digest
authenticationusername in interface DownloadSpecusername - the usernamepublic void password(java.lang.String password)
DownloadSpecBasic or Digest
authenticationpassword in interface DownloadSpecpassword - the passwordpublic void authScheme(java.lang.String authScheme)
DownloadSpecSets the authentication scheme to use. This method accepts
either a String (valid values are "Basic"
and "Digest").
If username and password are set this
method will only accept "Basic" or "Digest"
as valid values. The default value will be "Basic" in
this case.
authScheme in interface DownloadSpecauthScheme - the authentication schemepublic void headers(java.util.Map<java.lang.String,java.lang.String> headers)
DownloadSpecheaders in interface DownloadSpecheaders - a Map of header names to valuespublic void header(java.lang.String name,
java.lang.String value)
DownloadSpecheader in interface DownloadSpecname - name of the HTTP headervalue - value of the HTTP headerpublic void acceptAnyCertificate(boolean accept)
DownloadSpecacceptAnyCertificate in interface DownloadSpecaccept - true if certificate errors should be ignored (default: false)public void connectTimeout(int milliseconds)
DownloadSpecconnectTimeout in interface DownloadSpecmilliseconds - the timeout in milliseconds (default: -1)public void readTimeout(int milliseconds)
DownloadSpecreadTimeout in interface DownloadSpecmilliseconds - the timeout in milliseconds (default: -1)public void retries(int retries)
DownloadSpecretries in interface DownloadSpecretries - the maximum number of retries (default: 0)public void downloadTaskDir(java.lang.Object dir)
DownloadSpecdownloadTaskDir in interface DownloadSpecdir - the directory (default: ${buildDir}/gradle-download-task)public void tempAndMove(boolean tempAndMove)
DownloadSpecDownloadSpec.downloadTaskDir(Object);tempAndMove in interface DownloadSpectempAndMove - true if the file should be downloaded to a temporary
location and, upon successful execution, moved to the final location
(default: false)public void useETag(java.lang.Object useETag)
DownloadSpecSets the useETag flag. Possible values are:
true: check if the entity tag (ETag) of a downloaded
file has changed and issue a warning if a weak ETag was encounteredfalse: Do not use entity tags (ETags) at all"all": Use all ETags but do not issue a warning for weak ones"strongOnly": Use only strong ETagsNote that this flag is only effective if onlyIfModified is
true.
useETag in interface DownloadSpecuseETag - the flag's new valuepublic void cachedETagsFile(java.lang.Object location)
DownloadSpeccachedETagsFile in interface DownloadSpeclocation - the location (default: ${downloadTaskDir}/etags.json)@Input public java.lang.Object getSrc()
getSrc in interface DownloadSpec@Internal public java.io.File getDest()
getDest in interface DownloadSpec@Console public boolean isQuiet()
isQuiet in interface DownloadSpec@Input public boolean isOverwrite()
isOverwrite in interface DownloadSpec@Input public boolean isOnlyIfModified()
isOnlyIfModified in interface DownloadSpec@Input public boolean isOnlyIfNewer()
DownloadSpeconlyIfNewer flag. This method is an alias for
DownloadSpec.isOnlyIfModified().isOnlyIfNewer in interface DownloadSpec@Input public boolean isCompress()
isCompress in interface DownloadSpec@Input @Optional public java.lang.String getUsername()
getUsername in interface DownloadSpecBasic or Digest
authentication@Input @Optional public java.lang.String getPassword()
getPassword in interface DownloadSpecBasic or Digest
authentication@Input @Optional public java.lang.String getAuthScheme()
getAuthScheme in interface DownloadSpecnull if
no authentication is performed)@Input @Optional public java.util.Map<java.lang.String,java.lang.String> getHeaders()
getHeaders in interface DownloadSpecpublic java.lang.String getHeader(java.lang.String name)
getHeader in interface DownloadSpecname - name of the HTTP header@Input public boolean isAcceptAnyCertificate()
isAcceptAnyCertificate in interface DownloadSpec@Input public int getConnectTimeout()
getConnectTimeout in interface DownloadSpec@Input public int getReadTimeout()
getReadTimeout in interface DownloadSpec@Input public int getRetries()
getRetries in interface DownloadSpec@Internal public java.io.File getDownloadTaskDir()
getDownloadTaskDir in interface DownloadSpec@Input public boolean isTempAndMove()
isTempAndMove in interface DownloadSpec@Input @Optional public java.lang.Object getUseETag()
getUseETag in interface DownloadSpecuseETag flagDownloadSpec.useETag(Object)@Internal public java.io.File getCachedETagsFile()
getCachedETagsFile in interface DownloadSpec