de.undercouch.gradle.tasks.download
Class DownloadAction

java.lang.Object
  extended by de.undercouch.gradle.tasks.download.DownloadAction
All Implemented Interfaces:
DownloadSpec

public class DownloadAction
extends java.lang.Object
implements DownloadSpec

Downloads a file and displays progress


Constructor Summary
DownloadAction(org.gradle.api.Project project)
          Creates a new download action
 
Method Summary
 void acceptAnyCertificate(boolean accept)
          Specifies if HTTPS certificate verification errors should be ignored and any certificate (even an invalid one) should be accepted.
 void compress(boolean compress)
          Specifies if compression should be used during download
 void dest(java.lang.Object dest)
          Sets the download destination
 void execute()
          Starts downloading
 java.io.File getDest()
           
 java.lang.String getHeader(java.lang.String name)
           
 java.util.Map<java.lang.String,java.lang.String> getHeaders()
           
 java.lang.String getPassword()
           
 java.lang.Object getSrc()
           
 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 us when downloading
 boolean isAcceptAnyCertificate()
           
 boolean isCompress()
           
 boolean isOnlyIfNewer()
           
 boolean isOverwrite()
           
 boolean isQuiet()
           
 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 authentication
 void quiet(boolean quiet)
          Sets the quiet flag
 void src(java.lang.Object src)
          Sets the download source URL
 void username(java.lang.String username)
          Sets the username for Basic authentication
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DownloadAction

public DownloadAction(org.gradle.api.Project project)
Creates a new download action

Parameters:
project - the project to be built
Method Detail

execute

public void execute()
             throws java.io.IOException
Starts downloading

Throws:
java.io.IOException - if the file could not downloaded

src

public void src(java.lang.Object src)
         throws java.net.MalformedURLException
Description copied from interface: DownloadSpec
Sets the download source URL

Specified by:
src in interface DownloadSpec
Parameters:
src - the URL
Throws:
java.net.MalformedURLException - if the download source is not a URL

dest

public void dest(java.lang.Object dest)
Description copied from interface: DownloadSpec
Sets the download destination

Specified by:
dest in interface DownloadSpec
Parameters:
dest - a file or directory where to store the retrieved file

quiet

public void quiet(boolean quiet)
Description copied from interface: DownloadSpec
Sets the quiet flag

Specified by:
quiet in interface DownloadSpec
Parameters:
quiet - true if download progress should not be logged

overwrite

public void overwrite(boolean overwrite)
Description copied from interface: DownloadSpec
Sets the overwrite flag

Specified by:
overwrite in interface DownloadSpec
Parameters:
overwrite - true if existing files should be overwritten, false otherwise

onlyIfNewer

public void onlyIfNewer(boolean onlyIfNewer)
Description copied from interface: DownloadSpec
Sets the onlyIfNewer flag

Specified by:
onlyIfNewer in interface DownloadSpec
Parameters:
onlyIfNewer - true if the file should only be downloaded if it has been modified on the server since the last download

compress

public void compress(boolean compress)
Description copied from interface: DownloadSpec
Specifies if compression should be used during download

Specified by:
compress in interface DownloadSpec
Parameters:
compress - true if compression should be enabled

username

public void username(java.lang.String username)
Description copied from interface: DownloadSpec
Sets the username for Basic authentication

Specified by:
username in interface DownloadSpec
Parameters:
username - the username

password

public void password(java.lang.String password)
Description copied from interface: DownloadSpec
Sets the password for Basic authentication

Specified by:
password in interface DownloadSpec
Parameters:
password - the password

headers

public void headers(java.util.Map<java.lang.String,java.lang.String> headers)
Description copied from interface: DownloadSpec
Sets the HTTP request headers to us when downloading

Specified by:
headers in interface DownloadSpec
Parameters:
headers - a Map of header names to values

header

public void header(java.lang.String name,
                   java.lang.String value)
Description copied from interface: DownloadSpec
Sets an HTTP request header to use when downloading

Specified by:
header in interface DownloadSpec
Parameters:
name - name of the HTTP header
value - value of the HTTP header

acceptAnyCertificate

public void acceptAnyCertificate(boolean accept)
Description copied from interface: DownloadSpec
Specifies if HTTPS certificate verification errors should be ignored and any certificate (even an invalid one) should be accepted. By default certificates are validated and errors are not being ignored.

Specified by:
acceptAnyCertificate in interface DownloadSpec
Parameters:
accept - true if certificate errors should be ignored (default: false)

getSrc

public java.lang.Object getSrc()
Specified by:
getSrc in interface DownloadSpec
Returns:
the download source(s), either a URL or a list of URLs

getDest

public java.io.File getDest()
Specified by:
getDest in interface DownloadSpec
Returns:
the download destination

isQuiet

public boolean isQuiet()
Specified by:
isQuiet in interface DownloadSpec
Returns:
the quiet flag

isOverwrite

public boolean isOverwrite()
Specified by:
isOverwrite in interface DownloadSpec
Returns:
the overwrite flag

isOnlyIfNewer

public boolean isOnlyIfNewer()
Specified by:
isOnlyIfNewer in interface DownloadSpec
Returns:
the onlyIfNewer flag

isCompress

public boolean isCompress()
Specified by:
isCompress in interface DownloadSpec
Returns:
true if compression is enabled

getUsername

public java.lang.String getUsername()
Specified by:
getUsername in interface DownloadSpec
Returns:
the username for Basic authentication

getPassword

public java.lang.String getPassword()
Specified by:
getPassword in interface DownloadSpec
Returns:
the password for Basic authentication

getHeaders

public java.util.Map<java.lang.String,java.lang.String> getHeaders()
Specified by:
getHeaders in interface DownloadSpec
Returns:
the HTTP request headers to use when downloading

getHeader

public java.lang.String getHeader(java.lang.String name)
Specified by:
getHeader in interface DownloadSpec
Parameters:
name - name of the HTTP header
Returns:
the value of the HTTP header

isAcceptAnyCertificate

public boolean isAcceptAnyCertificate()
Specified by:
isAcceptAnyCertificate in interface DownloadSpec
Returns:
true if HTTPS certificate verification errors should be ignored, default value is false