ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Anderson, Rob (Global Trade)" <>
Subject RE: logic using ant
Date Tue, 08 Mar 2005 18:04:24 GMT
This is certainly possible. Depending on what exactly you are trying to do, your method to
acheive it may differ. Here is one method I use to get the same thing done in different environments.

I create a properties file for each environment:

In the properties files, I put environment specific stuff, like the following:

Then I would have a build.xml that looks like this:

<project name="example" default="build">
  <available file="${env}.properties" property="prop.file.exists"/>
  <fail unless="prop.file.exists">Can't find ${env}.properties</fail>
  <property file="${env}.properties"/>

  <target name="build" depends="dosomething">
    <!-- Do stuff here using the properties set in ${env}.properties -->

  <target name="dosomething" if="DOSOMETHING">
    <!-- Do not set DOSOMETHING in the ${env}.properties if you don't need this done. -->

Then I call ant with the following command:
ant -Denv=dev build\

The dosomething target will always get called, but will only execute if the DOSOMETHING property
is set. So I don't set this in, perhaps.

I hope this helps,

-Rob Anderson

> -----Original Message-----
> From: klute []
> Sent: Monday, March 07, 2005 2:32 PM
> To:
> Subject: logic using ant
> hey guys
> i have a dev and test environments with the former
> being on win xp and the latter on linux. i am trying
> to put some logic within my build target to do things
> differently. i'd like to do this to avoid separate
> targets for dev and text environments. here is some
> basic pseudo code of what i am trying to achieve:
> if some env variable indicates that the script is
> running in windows env {
>    do this
> } else {
>    do that
> }
> is this possible? 
> thanks a lot!
> james
> __________________________________ 
> Celebrate Yahoo!'s 10th Birthday! 
> Yahoo! Netrospective: 100 Moments of the Web 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message