public class DownloadAction extends java.lang.Object implements DownloadSpec
| Constructor and Description |
|---|
DownloadAction(org.gradle.api.Project project)
Creates a new download action
|
DownloadAction(org.gradle.api.Project project,
org.gradle.api.Task task)
Creates a new download action
|
| 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 |
downloadTaskDir(java.lang.Object dir)
Specifies the directory where gradle-download-task stores information
that should persist between builds
|
java.util.concurrent.CompletableFuture<java.lang.Void> |
execute()
Starts downloading
|
java.util.concurrent.CompletableFuture<java.lang.Void> |
execute(boolean throwOnError)
Starts downloading
|
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() |
boolean |
isUpToDate() |
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
|
public DownloadAction(org.gradle.api.Project project)
project - the project to be builtpublic DownloadAction(org.gradle.api.Project project,
@Nullable
org.gradle.api.Task task)
project - the project to be builttask - the task to be executed, if applicablepublic java.util.concurrent.CompletableFuture<java.lang.Void> execute()
throws java.io.IOException
CompletableFuture that completes once the download
has finishedjava.io.IOException - if the file could not downloadedpublic java.util.concurrent.CompletableFuture<java.lang.Void> execute(boolean throwOnError)
throws java.io.IOException
throwOnError - true if the asynchronous worker action should
throw if the download fails. false if only the returned
CompletableFuture should complete exceptionally.CompletableFuture that completes once the download
has finishedjava.io.IOException - if the file could not downloadedpublic boolean isUpToDate()
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)public java.lang.Object getSrc()
getSrc in interface DownloadSpecpublic java.io.File getDest()
getDest in interface DownloadSpecpublic boolean isQuiet()
isQuiet in interface DownloadSpecpublic boolean isOverwrite()
isOverwrite in interface DownloadSpecpublic boolean isOnlyIfModified()
isOnlyIfModified in interface DownloadSpecpublic boolean isOnlyIfNewer()
DownloadSpeconlyIfNewer flag. This method is an alias for
DownloadSpec.isOnlyIfModified().isOnlyIfNewer in interface DownloadSpecpublic boolean isCompress()
isCompress in interface DownloadSpecpublic java.lang.String getUsername()
getUsername in interface DownloadSpecpublic java.lang.String getPassword()
getPassword in interface DownloadSpecpublic 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 headerpublic boolean isAcceptAnyCertificate()
isAcceptAnyCertificate in interface DownloadSpecpublic int getConnectTimeout()
getConnectTimeout in interface DownloadSpecpublic int getReadTimeout()
getReadTimeout in interface DownloadSpecpublic int getRetries()
getRetries in interface DownloadSpecpublic java.io.File getDownloadTaskDir()
getDownloadTaskDir in interface DownloadSpecpublic boolean isTempAndMove()
isTempAndMove in interface DownloadSpecpublic java.lang.Object getUseETag()
getUseETag in interface DownloadSpecuseETag flagDownloadSpec.useETag(Object)public java.io.File getCachedETagsFile()
getCachedETagsFile in interface DownloadSpec