austin java users group 2005-feb-22 presented by matt albrecht

20
Austin Java Users Group 2005-Feb-22 Presented by Matt Albrecht

Upload: sydney-robinson

Post on 13-Dec-2015

214 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Austin Java Users Group 2005-Feb-22 Presented by Matt Albrecht

Austin Java Users Group2005-Feb-22

Presented by Matt Albrecht

Page 2: 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:

http://antlion.sf.net Apache 2.0 License

Page 3: Austin Java Users Group 2005-Feb-22 Presented by Matt Albrecht

Problem: Dependencies Build relies on external libraries,

which need definitions in Ant: Properties Filesets Paths

Page 4: Austin Java Users Group 2005-Feb-22 Presented by Matt Albrecht

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

Page 5: Austin Java Users Group 2005-Feb-22 Presented by Matt Albrecht

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

Page 6: Austin Java Users Group 2005-Feb-22 Presented by Matt Albrecht

Quick Look Define a policy for repository

setup, library entry meta-data, and what to do with Ant.

Declare library groups and their entries.

Page 7: Austin Java Users Group 2005-Feb-22 Presented by Matt Albrecht

Policies - Repositories<library-policy id=“policy”>

<repository basedir=“${thirdparty.dir}”>

<format text=“[prj]/[version]/[name].[type]”/>

<format text=

“[prj]/[version]/[name]-[version].[type]” />

<format text=

“[prj]/[version]/[prj]-[version].[type]” />

<format text=

“[prj]/[version]/[prj].[type]” />

</repository>

Page 8: Austin Java Users Group 2005-Feb-22 Presented by Matt Albrecht

Policies – Remote repositories

<urlrepository cachedir=“${cache}”

remote=“ftp://internal/repository”

format=“[prj]/[name]-[version].[type]” />

<mavenrepository cachedir=“${maven.cache}” />

Page 9: Austin Java Users Group 2005-Feb-22 Presented by Matt Albrecht

Policies – Working with Libs

<attribute attributes=“prj, version” />

<version-check versionAttribute=“version”

matchAttributes=“prj, name, type” />

<must-find />

Page 10: Austin Java Users Group 2005-Feb-22 Presented by Matt Albrecht

Policies – Populating Ant

<property format=“lib.[prj].[name]” />

<fileset />

<filelist />

<path />

<manifest-classpath />

Page 11: Austin Java Users Group 2005-Feb-22 Presented by Matt Albrecht

Defining Libraries<libraryDef policyRef=“policy”>

<library id=“lib.xerces” prj=“xerces”

version=“2.6.2”>

<lib-entry name=“xercesImpl” />

<lib-entry name=“xmlParserAPIs” />

</library>

Page 12: Austin Java Users Group 2005-Feb-22 Presented by Matt Albrecht

Defining Libraries <library id=“compile”>

<library refid=“lib.xerces” />

<lib-entry prj=“junit” version=“3.8.1” />

</library>

</libraryDef>

Page 13: Austin Java Users Group 2005-Feb-22 Presented by Matt Albrecht

Using the Libraries<echo>${lib.xerces.xercesImpl}</echo>

<javac …>

<classpath refid=“path.compile” />

</javac>

<copy todir=“${out}/WEB-INF/lib” flatten=“true”>

<fileset refid=“fileset.lib.xerces” />

</copy>

Page 14: Austin Java Users Group 2005-Feb-22 Presented by Matt Albrecht

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.

Page 15: Austin Java Users Group 2005-Feb-22 Presented by Matt Albrecht

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.

Page 16: Austin Java Users Group 2005-Feb-22 Presented by Matt Albrecht

Solution in Antlion <artifact> defines an output of a build,

the build file target, and can include all of its dependencies.

<artifact> file references are relative to the file containing the <artifact> tag, not basedir. This makes it easy to import artifacts.

<artifact> can be added to a <library>. <subprojects> allows for constructing

targets with the correct should-build logic.

Page 17: Austin Java Users Group 2005-Feb-22 Presented by Matt Albrecht

Quick Look: artifacts.xml<project name=“mybuild-artifact”>

<artifact id=“mybuild.jar”

target=“jar” artifact=“export/mybuild.jar”>

<src><include name=“src/**/*.java” /></src>

<depends type=“build”>

<library refid=“lib.xerces” />

</depends>

</artifact>

</project>

Page 18: Austin Java Users Group 2005-Feb-22 Presented by Matt Albrecht

Referencing Other Builds<import file=“../mybuild/artifacts.xml” />

<subprojects UseArtifactTarget=“false”

prefix=“SUB”>

<project name=“module” targets=“main”

antfile=“module/build.xml” />

<artifact refid=“mybuild.jar” />

</subprojects>

<target name=“all”

depends=“SUB::module::main, SUB::mybuild.jar”/>

Page 19: Austin Java Users Group 2005-Feb-22 Presented by Matt Albrecht

Using Artifacts in Libraries<libraryDef policyRef=“policy”>

<library id=“other-build”>

<artifact refid=“mybuild.jar” />

<dependencies type=“build”

artifactRefId=“mybuild.jar” />

</library>

</libraryDef>

Page 20: Austin Java Users Group 2005-Feb-22 Presented by Matt Albrecht

Summary Antlion helps you:

Get your libraries organized, and let the tool do the dirty work for you.

Simplify management of inter-project dependencies.