ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "G.L. Grobe" <g...@grobe.net>
Subject Re: dynamic properties
Date Wed, 22 May 2002 01:21:59 GMT
Using Ant 1.4.1, what's the best way to test if a property is of a certain
value so that I may set other props ... so if I have the following ....

    <condition property="platform" value="Linux">
         <os name="Linux">
    </condition>

I'd then like to say something like ... (it's wrong, but read as ...)

<if os.name == "linux">
    <property name="my.dir" value="this.path"/>
<elseif os.name == "mac">
    <property name="my.dir" value="that.path"/>
</if>


----- Original Message -----
From: "Dominique Devienne" <DDevienne@lgc.com>
To: "'Ant Users List'" <ant-user@jakarta.apache.org>
Sent: Tuesday, May 21, 2002 2:23 PM
Subject: RE: dynamic properties


> I guess the simplest way would be to have a properties file per-platform,
> and simply load it using:
>
> <property file="${basedir}/build-${platform}.properties" />
>
> You just have to come up with a way to define properties so that it suits
> your needs. This can be achieved different ways, for example in an 'init'
> target (hopefully <condition> respects immutability of properties in
> 1.4.1!):
>
> <target name="init">
>   <condition property="platform" value="win32">
>     <os family="windows" />
>   </condtion>
>   <condition property="platform" value="unix">
>     <os family="unix" />
>   </condtion>
>
>   <property file="${basedir}/build-${platform}.properties" />
> </target>
>
> It would be nice to be able to access an os.family property direclty
instead
> of having to do multiple <condition>s though...
>
> Or if you prefer to have everything in build.xml, then you use targets:
>
> <target name="set-properties"
>         depends="set-platform, set-properties.win32, set-properties.unix">
>   <!-- properties common to all platforms -->
>   <property name="common-prop" value="blah blah" />
> </target>
>
> <target name="set-platform">
>   <condition property="platform.win32">
>     <os family="windows" />
>   </condtion>
>   <condition property="platform.unix">
>     <os family="unix" />
>   </condtion>
> </target>
>
> <target name="set-properties.win32"
>         if="platform.win32">
>   <property name="some-prop" value="win32 blee blee" />
> </target>
>
> <target name="set-properties.unix"
>         if="platform.unix">
>   <property name="some-prop" value="unix blee blee" />
> </target>
>
> If use can use Ant 1.5 beta with ant-contrib's <if> task, then it should
be
> pretty straightforward to do what you want. Don't have either, so you're
on
> your own ;-) --DD
>
> -----Original Message-----
> From: Gary Grobe [mailto:gary@grobe.net]
> Sent: Tuesday, May 21, 2002 1:59 PM
> To: ant-user@jakarta.apache.org
> Subject: dynamic properties
>
> I'm looking for a way to say, if this platform then set these
> properties, else if this platform, then set the same properties for the
> same target, but with different values. Found a few ways  but am hoping
> for something better.
>
> Thnxs.
>
>
> --
> To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>
>
> --
> To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>
>
>


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


Mime
View raw message