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.
Main Topics Oldest First

Showing messages 1 through 1 of 1.

  • Location independance
    2005-09-16 05:48:29  LesHazlewood [View]

    I agree with you. At the time I made the sample application, I was wondering about the best way to do this.

    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):

    <?xml version="1.0"?>

    <project name="someName" default="dist">

    <property name="root.base.dir" value="../">

    <import file="../build.xml"/>

    ...
    </project>


    And for a submodule:

    <?xml version="1.0"?>

    <project name="someName" default="dist">

    <property name="root.base.dir" value="../../">

    <import file="../build.xml"/>

    ...
    </project>


    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