ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Anderson, Rob (Global Trade)" <Rob.Ander...@nike.com>
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:
dev.properties
test.properties

In the properties files, I put environment specific stuff, like the following:
dev.properties
###############
HOSTNAME=localhost
DEPLOYPATH=C:\some\path\to\deploy\stuff\
DOSOMETHING=TRUE

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>

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

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 test.properties, perhaps.

I hope this helps,

-Rob Anderson

> -----Original Message-----
> From: klute [mailto:soundres9@yahoo.com]
> Sent: Monday, March 07, 2005 2:32 PM
> To: user@ant.apache.org
> 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 
> http://birthday.yahoo.com/netrospective/
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
> 
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message