Search code examples
antbuildcruisecontrol

Overriding Environment Variables in an Ant Script


I have an issue where my automated build environment necessitates a different version of ant than the actual delegated scripts being run to produce the build.

I do not have an environmental variable for ANT_HOME. I throw my CI environment the ANT_HOME to a directory of ant-1.7.0 But i need to override or unset ANT_HOME to a directory of ant-1.6.5 so the targets I call don't inherit the ANT_HOME, and run out of the 1.7.0 folder.

Can anyone think of a good way to do this? I can't modify the delegated targets of the build script but I can modify anything in the front end.

I'm using Cruisecontrol2.8.4 and the aforementioned ant versions.

Edit: The build targets I call set their own ANT_HOME to the 1.6.5 folder but it is being ignored as the previously set ANT_HOME to invoke cruisecontrol is immutable


Solution

  • You can unset properties with AntContrib.

    In your ant script...

    Import AntContrib:

    <taskdef resource="net/sf/antcontrib/antlib.xml">
        <classpath>
            <pathelement location="folderwithantcontribjar/ant-contrib-1.0b3.jar"/>
        </classpath>
    </taskdef>
    

    Do the unset:

    <var name="ANT_HOME" unset="true"/>
    

    This removes ANT_HOME from the current set of properties allowing it to be set again.