Welcome, Guest
Username Password: Remember me

Condition with Task in Ant
(1 viewing) (1) Guest
Apache Ant
  • Page:
  • 1

TOPIC: Condition with Task in Ant

Condition with Task in Ant 1 year, 6 months ago #385

  • scmuser
  • OFFLINE
  • Gold Boarder
  • scm master
  • Posts: 237
  • Points: 3421
  • Karma: 0
  • Honor Medal 2009
Hi,

How can i use conditions in Ant Task execution?


Any idea?

Re: Condition with Task in Ant 1 year, 6 months ago #387

  • tpatil
  • OFFLINE
  • Junior Boarder
  • Posts: 27
  • Points: 5095
  • Karma: 0
  • Honor Medal 2009
 
[i]<target name="check-props">
 
<!-- Ensure that entry doesn't exists in list -->
<condition property="entry-exists">
<contains string="${tag.list}" substring="${build.label}" />
</condition>
<fail if="entry-exists" message="Entry already exists.Please specify another." />
 
<!-- Ensure dir is configured correctly and exists-->
<condition property="dir-configured">
<and>
<isset property="dir" />
<available file="${dir}" type="dir" />
</and>
</condition>
<fail unless="dir-configured" message="dir not configured" />
 
</target>
 
<!-- Execute the ant based on condition is set or not -->
<target name="-set-props-if-set" if="property1">
<property name="property2" value="string1"/>
<property name="property3" value="string2"/>
</target>
 
<target name="-set-props-if-not-set" unless="property1">
<property name="property2" value="string2"/>
<property name="property3" value="string1"/>
</target>[/i]

Re: Condition with Task in Ant 1 year, 6 months ago #391

  • rajeshkumar
  • OFFLINE
  • Moderator
  • I love software configuration management
  • Posts: 370
  • Points: 44469
  • Karma: 4
  • Honor Medal 2009
Hi,

I guess questions was based on applying condition for Aant TASK instead of Ant Target. Following ways i mean using <condition> you can set the conditional properties value but set condition with TASK.

There is one external lib ant-contrib which can be used to put conditional Task such you can find more details in links below.....
ant-contrib.sourceforge.net/tasks/tasks/if.html
Regards,
Rajesh Kumar
Build and Release Engineer
My Blog: community.scmgalaxy.com/pg/profile/rajeshkumar
  • Page:
  • 1
Time to create page: 1.24 seconds

     
    
Home Forum