ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Bodewig <bode...@apache.org>
Subject Re: Conditional logic in ANT build scripts
Date Wed, 09 Apr 2003 07:06:09 GMT
On Wed, 9 Apr 2003, Andrew Zeon <AndrewZ@hothouse.com.au> wrote:

> I have targets which should only be run for specific
> environments... how can I do this?

The way I do it:

<property file="${environment.properties}"/>

at the top of the build file.  I'll most likely need different values
for a whole bunch of properties depending on the environment as well.

In life.properties I'd have a line

is-live=true

and I'd not define the same property in the other environments (but
similar properties with different names).

The conditional targets then would look like

<target name="run-only-for-live" if="is-live" ...

As a refinement (when using Ant >= 1.5) I'd drop the environment
property and the <property> above task completely and invoke Ant as

ant -propertyfile life.properties

Stefan

Mime
View raw message