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 |
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.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 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 authentication
|
compareTo, configure, dependsOn, doFirst, doFirst, doFirst, doLast, doLast, doLast, finalizedBy, getActions, getAnt, getDependsOn, getDescription, getDestroyables, getDidWork, getEnabled, getExtensions, getFinalizedBy, getGroup, getInputs, getLocalState, getLogger, getLogging, getMustRunAfter, getName, getOutputs, getPath, getProject, getShouldRunAfter, getState, getTaskDependencies, getTemporaryDir, getTimeout, hasProperty, mustRunAfter, onlyIf, onlyIf, property, setActions, setDependsOn, setDescription, setDidWork, setEnabled, setFinalizedBy, setGroup, setMustRunAfter, setOnlyIf, setOnlyIf, setProperty, setShouldRunAfter, shouldRunAfter, usesServiceappendParallelSafeAction, doNotTrackState, getAsDynamicObject, getConvention, getIdentityPath, getImpliesSubProjects, getOnlyIf, getReasonNotToTrackState, getRequiredServices, getServices, getSharedResources, getStandardOutputCapture, getTaskActions, getTaskIdentity, getTemporaryDirFactory, hasTaskActions, injectIntoNewInstance, isEnabled, isHasCustomActions, prependParallelSafeAction, setImpliesSubProjectspublic 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)
DownloadSpecusername in interface DownloadSpecusername - the usernamepublic void password(java.lang.String password)
DownloadSpecpassword in interface DownloadSpecpassword - the passwordpublic 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 DownloadSpec@Input @Optional public java.lang.String getPassword()
getPassword in interface DownloadSpec@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