| Article: |
An Ant Modular Build Environment for Enterprise Applications | |
| Subject: | Location independance | |
| Date: | 2005-07-07 23:06:18 | |
| From: | vimeshev | |
| It is also important to keep build scripts location independent, or at least to minimize such dependancies. Satisfying this requirement makes it easy to run the project build under a continuous integration server such as Parabuild. | ||
Showing messages 1 through 2 of 2.
-
Location independance
2005-09-16 05:48:29 LesHazlewood [View]
-
Location independance
2006-08-02 11:25:42 RodMcDonald [View]
Great article, good ideas.
1. I found that the global-init target (in the top level build.xml) may specify the following
<property name="root.base.dir" value="./"/>
This has so far worked for me.
2. For template targets I needed to add inheritAll="false" so that ant invoking ant in another directory would set up the correct root.base.dir.
<target name="template" depends="prepare">
<ant target="${target}" dir="server" inheritAll="false"/>
<ant target="${target}" dir="client" inheritAll="false"/>
</target>



The problem with a hierarchical build is that each module must know the hierarchy's root directory to maintain references to other modules and submodules. This is key to enabling a build (via 'ant') at any level in the hierarchy.
So, the easiest way (and the way I used in the sample application) was to just specify the root directory as an absolute path. As you have noted, this requires developers to change that property to work on their system.
Ideally, it would be really nice to just do an RCS checkout and run the build, without having to change anything.
So, I use a little technique to make sure that doesn't happen -
Each module and submodule defines the root directory via a relative path before importing the parent's build file.
Because you define it before the import, that value won't be overridden by any parent definitions (remember, ant keeps the first value it finds).
This is accomplished via the following (for a module):
And for a submodule:
After making these simple respective adjustments in each module and submodule, you can do a fresh checkout and not have to modify any settings for paths. Much nicer...
Cheers,
Les