- 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
-
|
Subprojects
|
Large Ant projects generally run into the issue of breaking up a monolithic
build process into smaller, more manageable pieces. In the process, the
smaller pieces lose the nice dependency graph that Ant provides with the
depends . In its place, custom Ant script codifies this dependency
graph. Ant 1.6 supplied the <subant>
task to ease the burden of a master build file, but does nothing for
inter-project dependency analysis.
Antlion provides the <subprojects> Ant task to
allow for a cleaner solution. It provides a single place in a build file where
all the external build dependencies get defined, and allows for the target
dependency graph to still be defined in the targets.
Master Builds
|
Let's first look at how the <subprojects> task
fills the role of the master build file calling other builds. In this
example, we'll have the master build file, master.xml , call
out to other Ant files in the same directory, a.xml ,
b.xml , and c.xml . If a.xml and
b.xml each have public targets "all", "main", and "clean",
while c.xml has only "main", then master.xml will
look something like:
|
|
|
|
<project name="master" default="main">
<subprojects prefix="SUB">
<project name="a" antfile="a.xml"
targets="all, main, clean" />
<project name="b" antfile="b.xml"
targets="all, main, clean" />
<project name="c" antfile="c.xml"
targets="main" />
</subprojects>
<target name="main"
depends="SUB::a::main, SUB::b::main, SUB::c::main" />
<target name="clean"
depends="SUB::a::clean, SUB::b::clean" />
<target name="all"
depends="SUB::a::all, SUB::b::all, SUB::c::main" />
</project>
|
|
|
|
|
The <subprojects> task will create an
artificial Ant target for each listed target of the projects. Then, those
targets can be added wherever they are needed, to let Ant discover the
correct build order.
|
|
|
|
|