How-To Guides
Getting Started
Policy Strategies
Format Strings
Extending Antlion
First Tutorial: Simple
Ant Tasks
inner processors
inner repositories
Optional Tasks
About optional tasks

Since Antlion 0.3.0

This element represents a remote repository, much like the <library-mavenrepository>, but without the restrictions of Maven.

The <urlrepository> element, like all repositories, can either live inside a <libraryDef> or as a stand-alone datatype. In the stand-alone form, it needs to have an id so that a <libraryDef> may reference it.

The URL repository has a concept of snapshot versions, much like Maven. By setting "snapshotAttribute" and "snapshotValue", entries with an attribute set to a specific value (case insensitive), corresponding to those settings, will be considered "snapshot" versions. A snapshot means that even if a cached version of the file exists, the remote version will still be downloaded. However, if the "online" attribute is "false" (it defaults to "true"), then only cached versions of the files will be retrieved, even if they're snapshot versions.

The files found in the remote repository will be downloaded to the local filesystem when the <libraryDef> attempts to find the files (that is, wherever the <libraryDef> task containing the <urlrepository> is located in the Ant file).

By default, all downloaded files will be put inside the local cache directory in the same directory structure as the repository contains them. This can be changed by setting the cacheFormat attribute to a format detailing where the file should go in the local cache based on the file's attributes. If the format isn't matched by the local cache, then the build will fail, unless the failCacheToDefault is enabled, in which case the file will be put into the same relative path as the remote repository stores it.

If you need to go through a firewall, use the <setproxy> Ant task to set up the proxy first, or set those JVM properties in the ANT_OPTS environment variable before starting Ant.

The URL repository allows for adding one or more validation elements. At the moment, the only available validator is <md5>. However, you can add a custom validator as described here.

Attribute Description Required
cachedir Local directory to store all the downloaded repository files. Yes
remote The remote repository location (must be an URL). You can specify multiple repositories by separating each URL with a comma (",").

Note that any URL supported by Java can be used here, even ftp: or file:.
snapshotAttribute If set, then any entry with an attribute name corresponding to this value will be checked against the value set in "snapshotValue". If equal (ignoring case), then the entry is considered a snapshot version. By default, nothing is considered a snapshot version. No
snapshotValue The value that the snapshotAttribute of each entry is compared against for snapshot version detection. This value is case-insensitive. By default, the value is "snapshot". No
online A boolean value declaring if the current build is online (go ahead and pull from the remote repository) or not (use the cached version exclusively). In any production system, this should always be used, and be equal to a property that the user can override in case they're working in an off-line situation. The default value is "true". No
format Adds a format string to the repository. Yes, if no <format> elements are specified.
cacheFormat Since Antlion 0.3.1

Sets the format of the location where the locally cached files will be placed. If the format isn't matched on a file, then, based on the setting of failCacheToDefault, either the build will fail, or the repository's path will be used instead. The cacheFormat attribute defaults to using the repository's path.
failCacheToDefault Since Antlion 0.3.1

If a file doesn't match the cacheFormat, then, by default, the build will fail with a descriptive message. However, if instead you would like to "fail-over" to the repository's path for the file, then set this attribute to "true".
checkUpdates Since Antlion 0.4.0

By default, snapshot libraries will always be downloaded, unless offline, in which case the cached version is used; and non-snapshot library files will be downloaded only if there isn't a cached version. By enabling this parameter, Antlion will instead inspect the remote repository's timestamp (if available): for all libraries, if there is a cached version, then its date/timestamp is compared against the repository, and downloaded if out-of-date. This should only be used if you know that the remote repository supports time retrieval (such as what most HTTP servers provide).
if Since Antlion 0.6.0

Only use this repository if the named property is set (regardless of the property's value).
unless Since Antlion 0.6.0

Only use this repository if the named property is not set (regardless of the property's value).

Nested Elements


Adds a format to the repository.

Attribute Description Required
text The format text to add. Yes


Passes a username/password to the repository using basic HTTP authentication, which essentially passes the password in clear text.

Attribute Description Required
username Username for 'BASIC' http authentication. Yes
password Password for 'BASIC' http authentication. Yes


Asserts that a corresponding MD5 checksum file on the remote site exists, and that the downloaded file has the same MD5 checksum as the corresponding checksum file. If they do not match, then a log message is reported, and the downloaded file is considered to be a non-match.

Attribute Description Required
extension File extension to append to the URL to search for the MD5 checksum file. No, defaults to ".md5"

<property name="cachedir" location="cache" />
<property name="" value="true" />
    <urlrepository cachedir="${cachedir}" online=${}"
        <format text="[project]/[artifact].[type]" />

        <lib-entry project="common" artifact="common-utils" />
Tries to download the library from to the local file cache/common-utils.jar. If the file cache/common-utils.jar already exists, then it will pull from this. If this cache file doesn't exist, and ${} is set to "false" by the user, then the entry will not be found, and the build will fail.
    <urlrepository remote=",
  " online="${}"
            cachedir="${user.home}/.maven/repository" />

        <lib-entry groupid="log4j" artifactid="log4j" version="SNAPSHOT" />
This example sets up the URL repository to be a Maven repository, but without the use of the Maven properties. This tries to pull the log4j library first from the local cache at ${user.home}/.maven/repository/log4j/jars/log4j-SNAPSHOT.jar, then the intranet FTP site, then the public Maven repository. In this case, the log4j entry is recognized as a snapshot version, and so it will always be downloaded from the internet as long as the ${} property is true, regardless if the local cached version exists or not.

Document version $Revision: 1.9 $ $Date: 2005/12/21 16:50:38 $

SourceForge Logo
Copyright © 2004-2006, The Antlion Project