ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jan.Mate...@rzf.fin-nrw.de
Subject RE: Conditionally setting property values
Date Mon, 09 Feb 2004 07:06:13 GMT
First I try

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

with a bundle of files

  windows.properties
  unix.properties
  ...


Jan



> -----Original Message-----
> From: Antoine Lévy-Lambert [mailto:antoine@antbuild.com]
> Sent: Saturday, February 07, 2004 11:32 AM
> To: Ant Users List
> Subject: Re: Conditionally setting property values
> 
> 
> Steven Scheffler wrote:
> 
> >You can achieve the below by using the ant-contrib package.  Go here
> >(http://ant-contrib.sourceforge.net/) to download.
> >
> >Using the <if> task you can express the if/then/else type 
> logic you're
> >looking for.
> >
> >-----Original Message-----
> >From: Holliday, Donald B. (LNG-CSP) 
> [mailto:Donald.Holliday@lexisnexis.com] 
> >Sent: Friday, February 06, 2004 5:39 PM
> >To: 'Ant Users List'
> >Subject: Conditionally setting property values
> >
> >I have ant build scripts that need to run on both Win2K and 
> Solaris.  The
> >JDK/SDKs, JREs, and locally constructed jar files are in different
> >directories, depending on the operating system.
> >
> >I want to write a script that says something like
> >	<if os.arch="windows" >
> >		set a bunch of properties
> >	</if>
> >	<if os.arch="unix" >
> >		set the same properties, only to different values
> >	</if>
> >
> ><condition> provides "if" like properties, but I can't see 
> how this allows
> >me to set many properties to different values based on one 
> condition test.
> >
> >Is there an easy way to do this?  If there is, what is it?
> >
> >Thanks,
> >
> >Donald Holliday
> >
> >  
> >
> There is also a possibility using vanilla ant to do the 
> equivalent. You 
> need to use specific targets to set "flag" properties, then use these 
> flag properties with the if and unless clauses of other targets.
> 
> For instance
> 
> <target name="checkos">
>     <condition property="onwindows">
>           <os family="windows"/>
>     </condition>
>     <condition property="onunix">
>           <os family="unix"/>
>     </condition>
> </target>
> 
> <target name="setwindowsproperties" if="onwindows">
>     <!-- define your windows specific properties here -->
> </target>
> 
> <target name="setunixproperties" if="onunix">
>     <!-- define your unix properties here -->
> </target>
> 
> <target name="setproperties" 
> depends="checkos,setwindowsproperties,setunixproperties"/>
> 
> If you write such a build file and start ant setproperties, 
> you will do 
> what you want.
> 
> Cheers,
> 
> Antoine
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
> 

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message