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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to