ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Scot P. Floess" <>
Subject Re: How to set properties when property is set
Date Tue, 23 May 2006 11:11:28 GMT
Well you could certainly use targets with the if/unless attributes...

For instance:

<project  name = "test"  default = "all">
  <property name="gen.dir" value="/vobs/rbs/sw/rbssw_boam/boam_subsys/boam_swb/boammao_swu/src/iface/gen"/>
  <available file="${gen.dir}" property="gen.dir.present"/>

  <target name = "setPropsPresent"  if = "gen.dir.present"
      <!-- Set your properties if present -->

  <target name = "setPropsNotPresent"  unless = "gen.dir.present"
      <!-- Set your properties if NOT present -->
  <target name = "all"  depends = "setPropsPresent, setPropsNotPresent"/>

Personally, ant contrib has an <if> task that might feel more natural so 
you don't have to use <target>'s in this way.  I am finding more and 
more I rely on ant contrib.  The script would might look something like:

<project  name = "test">
  <taskdef  resource = "net/sf/antcontrib/antlib.xml"/>

  <property name="gen.dir" value="/vobs/rbs/sw/rbssw_boam/boam_subsys/boam_swb/boammao_swu/src/iface/gen"/>

     <available file="${gen.dir}"/>

       <!-- Set your properties if present -->

       <!-- Set your properties if NOT present -->

Mikael Petterson (KI/EAB) wrote:
> Hi,
> I have a property that checks if a certain directory exists. If that
> property, gen.dir.present,  is true then 
> I need to set a bunch of properties. If false I set them to other
> values. Is there a 
> Smooth way to do this.
>  <property name="gen.dir"
> value="/vobs/rbs/sw/rbssw_boam/boam_subsys/boam_swb/boammao_swu/src/ifac
> e/gen"/>
>  <available file="${gen.dir}" property="gen.dir.present"/>
>  <echo message="New refactored structure for iface present:
> ${gen.dir.present}"/>
> Cheers,
> //mikael

Scot P. Floess
27 Lake Royale
Louisburg, NC  27549

252-478-8087 (Home)
919-754-4592 (Work)

Chief Architect JPlate
Chief Architect JavaPIM

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

View raw message