Austin Java Users Group 2005-Feb-22 Presented by Matt Albrecht
Quick Overview Helps organize libraries and inter- project dependencies in Ant build scripts. Requires Ant 1.6+, JDK 1.2+ Hosted on Sourceforge: Apache 2.0 License
Problem: Dependencies Build relies on external libraries, which need definitions in Ant: Properties Filesets Paths
Solutions Add and manage each type by hand. Wait for Ant 1.7, which has limited library support Use one of several Ant toolkits which gives Maven-like support
Solution in Antlion Antlion gives you: User-defined library repository structure Local and remote repositories Configurable generation of Ant references and properties Shorthand notation to keep builds simple and easy to read
Quick Look Define a policy for repository setup, library entry meta-data, and what to do with Ant. Declare library groups and their entries.
Policies - Repositories <format text= “[prj]/[version]/[name]-[version].[type]” /> <format text= “[prj]/[version]/[prj]-[version].[type]” /> <format text= “[prj]/[version]/[prj].[type]” />
Policies – Remote repositories <urlrepository cachedir=“${cache}” remote=“ftp://internal/repository” format=“[prj]/[name]-[version].[type]” />
Policies – Working with Libs <version-check versionAttribute=“version” matchAttributes=“prj, name, type” />
Policies – Populating Ant
Defining Libraries <library id=“lib.xerces” prj=“xerces” version=“2.6.2”>
Defining Libraries
Using the Libraries ${lib.xerces.xercesImpl}
Problem: Inter-build depends The build is divided into several “ modules, ” each with their own set of output files, called “ artifacts. ” Some modules depend upon other modules to be built. Dependencies upon dependencies. Build depends only when needed.
Solutions Hand code dependency building. Using ant-contrib with macrodefs can give you build-if-not-up-to-date functionality, but it can be tricky. Add paths within paths, but doesn ’ t scale to filesets.
Solution in Antlion defines an output of a build, the build file target, and can include all of its dependencies. file references are relative to the file containing the tag, not basedir. This makes it easy to import artifacts. can be added to a. allows for constructing targets with the correct should-build logic.
Quick Look: artifacts.xml <artifact id=“mybuild.jar” target=“jar” artifact=“export/mybuild.jar”>
Referencing Other Builds <subprojects UseArtifactTarget=“false” prefix=“SUB”> <project name=“module” targets=“main” antfile=“module/build.xml” /> <target name=“all” depends=“SUB::module::main, SUB::mybuild.jar”/>
Using Artifacts in Libraries <dependencies type=“build” artifactRefId=“mybuild.jar” />
Summary Antlion helps you: Get your libraries organized, and let the tool do the dirty work for you. Simplify management of inter-project dependencies.