Gets files from URLs. When the verbose option is "on", this task displays a '.' for every 100 Kb retrieved. Any URL schema supported by the runtime is valid here, including http:, ftp: and jar:;

The usetimestamp option enables you to control downloads so that the remote file is only fetched if newer than the local copy. If there is no local copy, the download always takes place. When a file is downloaded, the timestamp of the downloaded file is set to the remote timestamp. NB: This timestamp facility only works on downloads using the HTTP protocol.

A username and password can be specified, in which case basic 'slightly encoded plain text' authentication is used. This is only secure over an HTTPS link.

Proxies. Since Apache Ant 1.7.0, Ant running on Java1.5 or later can use the proxy settings of the operating system if enabled with the -autoproxy option. There is also the <setproxy> task for earlier Java versions. With proxies turned on, <get> requests against localhost may not work as expected, if the request is relayed to the proxy.


Attribute Description Required
src the URL from which to retrieve a file. Yes or a nested resource collection
dest the file or directory where to store the retrieved file(s). Yes
verbose show verbose progress information ("on"/"off"). No; default "false"
quiet Log errors only.("true"/"false"). No; default "false"
ignoreerrors Log errors but don't treat as fatal. No; default "false"
usetimestamp conditionally download a file based on the timestamp of the local copy. HTTP only No; default "false"
username username for 'BASIC' http authentication if password is set
password password: required if username is set
maxtime Maximum time in seconds a single download may take, otherwise it will be interrupted and treated like a download error. Since Ant 1.8.0 No: default 0 which means no maximum time
retries The number of attempts to make for opening the URI.
The name of the attribute 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.
since Ant 1.8.0
No; default "3"
skipexisting skip files that already exist on the local filesystem
since Ant 1.8.0
No; default "false"
httpusecaches HTTP only - if true, allow caching at the HttpUrlConnection level. if false, turn caching off.
Note this is only a hint to the underlying UrlConnection class, implementations and proxies are free to ignore the setting.
No; default "true"
useragent User-Agent HTTP header to send, starting with Ant 1.9.3 Ant will specify a User-Agent header of "Apache Ant VERSION" unless overridden by this attribute
since Ant 1.9.3
tryGzipEncoding When set to true Ant will tell the server it is willing to accept gzip encoding to reduce the amount of data to transfer and uncompress the content transparently.
Setting this to true also means Ant will uncompress .tar.gz and similar files automatically.
since Ant 1.9.5
No; default "false"

Parameters specified as nested elements

any resource collection

Resource Collections are used to select groups of URLs to download. If the collection contains more than one resource, the dest attribute must point to a directory if it exists or a directory will be created if it doesn't exist. The destination file name use the last part of the path of the source URL unless you also specify a mapper.


You can define name transformations by using a nested mapper element. You can also use any filenamemapper type in place of the mapper element.

The mapper will receive the resource's name as argument. Any resource for which the mapper returns no or more than one mapped name will be skipped. If the returned name is a relative path, it will be considered relative to the dest attribute.


  <get src="" dest="help/index.html"/>

Gets the index page of, and stores it in the file help/index.html.

  <get src="" 

Gets the PGP keys of Ant's (current and past) release managers, if the local copy is missing or out of date. Uses the verbose option for progress information.

  <get src="" 

Fetches some file from a server with access control. Because https is being used the fact that basic auth sends passwords in plaintext is moot if you ignore the fact that it is part of your build file which may be readable by third parties. If you need more security, consider using the input task to query for a password.

Using a macro like the following

  <macrodef name="get-and-checksum">
    <attribute name="url"/>
    <attribute name="dest"/>
      <local name="destdir"/>
      <dirname property="destdir" file="@{dest}"/>
      <get dest="${destdir}">
        <url url="@{url}"/>
        <url url="@{url}.sha1"/>
          <globmapper from="@{url}.sha1" to="@{dest}.sha"/>
          <globmapper from="@{url}" to="@{dest}"/>
      <local name="checksum.matches"/>
      <local name=""/>
      <checksum file="@{dest}" algorithm="sha" fileext=".sha"
      <condition property="">
        <equals arg1="${checksum.matches}" arg2="false"/>
      <fail if="">Checksum error</fail>

it is possible to download an artifacts together with its SHA1 checksum (assuming a certain naming convention for the checksum file, of course) and validate the checksum on the fly.

<get dest="downloads">
  <url url=""/> 
  <url url=""/>

Gets the index and FAQ pages of, and stores them in the directory downloads which will be created if necessary.