ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Scot P. Floess" <flo...@mindspring.com>
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>

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


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"/>

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

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

     <else>
       <!-- Set your properties if NOT present -->
     </else>
  </if>
</project>



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  http://sourceforge.net/projects/jplate
Chief Architect JavaPIM http://sourceforge.net/projects/javapim


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


Mime
View raw message