Antlion
Welcome
License
 
How-To Guides
Getting Started
Libraries
Artifacts
Subprojects
Repositories
Policy Strategies
Format Strings
Extending Antlion
FAQ
 
Tutorials
First Tutorial: Simple
 
Ant Tasks
<artifact>
<libraryDef>
<library>
<library-policy>
inner processors
inner repositories
<library-type>
<library-repository>
<library-urlrepository>
<library-mavenrepository>
<library-repositoryset>
<create-artifact>
<subprojects>
<run-subproject>
<replace-target>
 
Optional Tasks
About optional tasks
RegexpTokenFormatter
 
library-urlrepository

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.

Parameters
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:.
No
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.
No
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".
No
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).
No
if Since Antlion 0.6.0

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

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

Nested Elements

format

Adds a format to the repository.

Parameters
Attribute Description Required
text The format text to add. Yes


basicAuth

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

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


md5

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.

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


Examples
<property name="cachedir" location="cache" />
<property name="user.online" value="true" />
<libraryDef>
    <urlrepository cachedir="${cachedir}" online=${user.online}"
            remote="ftp://nightlybuilds.myintranet.com/nightly"
            cacheFormat="[artifact].[type]">
        <format text="[project]/[artifact].[type]" />
    </urlrepository>


    <library>
        <lib-entry project="common" artifact="common-utils" />
    </library>
</libraryDef>
Tries to download the library from ftp://nightlybuilds.myintranet.com/nightly/common/common-utils.jar 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 ${user.online} is set to "false" by the user, then the entry will not be found, and the build will fail.
<libraryDef>
    <urlrepository remote="http://files.myintranet.com/maven/repository,
            http://www.ibiblio.org/maven" online="${user.online}"
            format="[groupid]/[type]s/[artifactid]-[version].[type]"
            snapshotAttribute="version"
            cachedir="${user.home}/.maven/repository" />

    <library>
        <lib-entry groupid="log4j" artifactid="log4j" version="SNAPSHOT" />
    </library>
</libraryDef>
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 ${user.online} 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