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
 
libraryDef
Each included library will be "discovered" using the library definition's repository list, and will be processed by the library definition's type specification.

When the library definition executes, it will first try to locate each library element via the registered repositories, in order of their appearence. You can register your own repository implementation through a <taskdef>, if the default ones do not conform to your needs. Referenced libraries will not be located through this definition, but rather through the owning definition.

After finding the corresponding files, the definition will process each library with its registered library type. If no type is defined, then the default type is used instead. The default type is shown in the first example below.

There are some processors which run before the repositories find the file. From the default list, only the attribute processor runs before the processor. This allows the library's specific attributes to be passed to the owned entries before file detection, so that the entry list does not need to be as verbose.

As of Antlion 0.6.0, this task is aliased with <libraries>.

Parameters
Attribute Description Required
policyRef Since Antlion 0.4.0

To make site maintenance easier, you may add a reference to a <library-policy> which contains all the repository and setup type definitions of your projects. If this reference is set, then no other repositories, types, or policies may be added to the <libraryDef>.
No

Nested Elements

repository

This task has been deprecated in favor of the <library-policy> tag. It will be removed in Antlion 1.0.

A local repository of external project files. Generally contains only compiled (binary) files like Jars, but may include other artifacts like DTDs and XSD files. See the entry on the <library-repository> task for more details about setting this up.

There can be as many repositories as needed. They process the library entries (looking for their filesystem counterparts) in the order they appear in the Ant build file.

This element can also be a reference to any other repository type, by using the "refid" attribute.


urlrepository

This task has been deprecated in favor of the <library-policy> tag. It will be removed in Antlion 1.0.

A special kind of repository that allows for a remote repository with a local cache. See the entry on the <urlrepository> task for more details about setting this up.


mavenrepository

This task has been deprecated in favor of the <library-policy> tag. It will be removed in Antlion 1.0.

A special kind of repository that emulates the Maven repository usage, allowing for a remote repository with a local cache. See the entry on the <mavenrepository> task for more details about setting this up.


repositoryset

This task has been deprecated in favor of the <library-policy> tag. It will be removed in Antlion 1.0.

For completeness, you can add a <repositoryset> entry, although its usefulness is more for outside the libraryDef than inside it. It can also be used for logically containing different repository groups, if needed.


type

This task has been deprecated in favor of the <library-policy> tag. It will be removed in Antlion 1.0.

A library type definition that describes how the libraries will be processed to generate Ant properties and references. See the entry on the <library-type> task for more details about setting this up.

There can be only one type per library definition. If a type isn't specified, then the default type (described above) will be used.


library

A library definition includes one or more <library> tags. Each one defines a set of files to be grouped in a single library. See the section describing the library tag for details on its usage.


Examples
<library-policy id="site-policy">
  <type>
    <default />
    <version-check />
  </type>
  <repository basedir="${3rdparty.dir}"
    format="[group]/[version]/[artifact].[type]" />
</library-policy>

<libraryDef policyref="site-policy">
  <library id="lib.xdoclet" groupid="xdoclet" version="1.1">
    <lib-entry artifactid="xdoclet" />
    <lib-entry artifactid="j2ee-module" />
  </library>
</libraryDef>
Defines a library policy referenced by "site-policy". This is then used in a libraryDef to declare the type and repository setup. From this, the "lib.xdoclet" library is defined.
<libraryDef>
  <type>
    <path />
    <fileset />
    <attribute />
    <manifest-classpath />
    <property>
        <format text="[groupid].[artifactid]-[current].[type]" />
        <format text="[groupid].[artifactid]-[version].[type]" />
        <format text="[group].[artifact]-[current].[type]" />
        <format text="[group].[artifact]-[version].[type]" />
    </property>
  </type>
  <mavenrepository />
  <repository basedir="${3rdparty.dir}"
    format="[groupid]/[version]/[artifactid].[type]" />
  <repository basedir="${basedir}/.."
    format="[groupid]/distribute/[artifactid].[type]" />

  <library id="lib.xdoclet" groupid="xdoclet" version="1.1">
    <lib-entry artifactid="xdoclet" />
    <lib-entry artifactid="j2ee-module" />
  </library>

  <library id="lib.build" manifest-classpath="lib.build.man-cp">
    <lib-entry groupid="junit" version="3.8.1"
      artifactid="junit" />
    <library refid="lib.xdoclet" />
  </library>
</libraryDef>
        

This is the old style for using <libraryDef>, and will be removed in Antlion version 1.0.

This example creates a library definition that uses a type that matches the default type. This type tries to:

  1. Add to each <lib-entry> the attributes in the owning library.
  2. Add each entry into the Ant project property space based on its attributes that match each formatted text; if an element doesn't have an attribute in the formatted text, then that property is not added.
  3. Add a Path per library with a refid of "path.[id]".
  4. Add a FileSet per library with a refid of "fileset.[id]".
  5. Add a property, whose name is in the "manifest-classpath" attribute of the library, that can be set in the MANIFEST.MF classpath property.

It also registers three repositories, which search the lib-entries in this order:

  1. The Maven repository at ibiblio.com.
  2. A local 3rd party repository, where each file takes the given formatted text form.
  3. The files built by other sibling projects.


<libraryDef>
  <repository basedir="${3rdparty.dir}"
    format="[groupid]/[version]/[artifactid].[type]" />

  <library id="lib.build">
    <lib-entry groupid="junit" version="3.8.1"
      artifactid="junit" />
    <lib-entry groupid="ant" version="1.5.1"
      artifactid="optional" />
  </library>
</libraryDef>
        

This is the old style for using <libraryDef>, and will be removed in Antlion version 1.0.

Uses the default library type definition. It has one file-based repository. This will create several Ant types:

  • path: a <path> with refid "path.lib.build", containing the files ${3rdparty.dir}/junit/3.8.1/junit.jar and ${3rdparty.dir}/ant/1.5.1/optional.jar
  • fileset: a <fileset> with refid "fileset.lib.build", containing the patterns junit/3.8.1/junit.jar and ant/1.5.1/optional.jar, and the "dir" attribute is auto-detected to be ${3rdparty.dir}.
  • filelist: a <filelist> with refid "filelist.lib.build", containing the strings junit/3.8.1/junit.jar and ant/1.5.1/optional.jar, and the "dir" attribute is auto-detected to be ${3rdparty.dir}.


<libraryDef>
  <type>
    <default />
    <version-check />
  </type>
  <library id="lib.build">
    <artifact refid="a.jar" />
    <dependencies artifactRefId="a.jar" type="build" />
    <artifact refid="b.jar" />
    <dependencies artifactRefId="b.jar" type="build" />
  </library>
  <library id="lib.test">
    <artifact refid="a.jar" />
    <dependencies artifactRefId="a.jar" type="test" />
    <artifact refid="b.jar" />
    <dependencies artifactRefId="b.jar" type="test" />
  </library>
  <library id="lib.run">
    <artifact refid="a.jar" />
    <dependencies artifactRefId="a.jar" type="run" />
    <artifact refid="b.jar" />
    <dependencies artifactRefId="b.jar" type="run" />
  </library>
</libraryDef>
        
Doesn't use a repository, and instead requires all entries to be defined by a location. Here, we're only using artifact and dependency declarations, which already have been resolved to a location. The library-type extends the default type to include the version-check processor.

The three libraries declared all use the "a.jar" and "b.jar" artifacts, but include their different dependency types, depending on the particular library's purpose.


Document version $Revision: 1.17 $ $Date: 2005/10/05 22:10:59 $

SourceForge Logo
Copyright © 2004-2006, The Antlion Project