nkale (4) [Avatar] Offline
This question is related to Chapter 9, and managing master builds and child project builds.

I've been struggling with the issue of being able to manage inter-subproject dependencies, using Ant 1.6 while at the same time trying to use the techniques presented in this chapter.

I have a master build and 3 subprojects (say - common, A and B)
A depends on common.
B depends on common and A.
Each subproject will also have its own build file.

I also have a common-targets.xml which defines targets like compile, test and clean. Every subproject imports this file. The compile task uses a compile.classpath, which is set in the importing files.

I define all properties similar to Section 8.3 using a properties.xml file. Every subproject imports this file too.

The master build file sets a classpath, say a.classpath to point to the build classes of common.
<import file="properties.xml"/>

<path id="a.classpath">
<pathelement location="common/${build.classes}"/>

<target name="do-A">
<ant dir="A" target="${target}" inheritAll="false" inheritRefs="true"/>

Project A's build file will declare its compile.classpath as follows - i.e, it adds its library dependencies
<path id="compile.classpath">
<path refid="a.classpath"/>
<pathelement location="${myJars.jar}"/>

This will work when I run the targets from the masterbuild. But, when I run it from Project A's build file, it will not work, because it looks for a path named a.classpath, which is not available when this build runs in a stand-alone mode.

Any ideas on how I can make the child project builds be able to run even in a stand-alone mode? Or am I doing something wrong in setting up the build system this way?

ErikHatcher (211) [Avatar] Offline
Re: Running child project builds in stand-alone mode
Define your classpath in your common imported build file. The import task is not exclusive to just importing targets, it can define anything.

For a concrete example - look at Apache's jakarta-lucene-sandbox CVS repository, specifically the contribution directory an it's subdirectories.