ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tibor Strausz <Tibor.Stra...@tridion.com>
Subject if clause
Date Thu, 15 Aug 2002 15:18:33 GMT

i wonder how ant live would be if there would be an <if> task wich can hold
other task as its sub tasks.
the sub task gets executed when the if has a property which is true or set.

is ther shuch a task??
if not, why????

tibi


example i could do this
<!--========================================WITH IF
==================================================-->
  <target name="renameSourceFolder" depends="init" description="Rename old
source folder">
    <property name="moveToSrcDir"
location="${oldSrcDir}_${DSTAMP}-${TSTAMP}"/>
    <property name="moveToSrcIntegrationDir"
location="${oldSrcIntegrationDir}_${DSTAMP}-${TSTAMP}"/>
    <property name="moveToTDSCollectionDir"
location="${oldTDSCollectionDir}_${DSTAMP}-${TSTAMP}"/>
    <available file="${oldSrcDir}" type="dir" property="oldSrcDir.present"/>
    <available file="${oldSrcIntegrationDir}" type="dir"
property="oldSrcIntegrationDir.present"/>
    <available file="${oldTDSCollectionDir}" type="dir"
property="oldTDSCollectionDir.present"/>
<if value="${oldSrcDir.present}"> 
    <antcall target="moveDir">
       <param name="moveToDir" value="${moveToSrcDir}"/>  
       <param name="oldDir" value="${oldSrcDir}"/>  
    </antcall>
</if>
<if value="${oldSrcIntegrationDir.present}"> 
    <antcall target="moveDir">
       <param name="moveToDir" value="${moveToSrcIntegrationDir}"/>  
       <param name="oldDir" value="${oldSrcIntegrationDir}"/>  
    </antcall>
</if>
<if value="${oldTDSCollectionDir.present}"> 
    <antcall target="moveDir">
       <param name="moveToDir" value="${moveToTDSCollectionDir}"/>  
       <param name="oldDir" value="${oldTDSCollectionDir}"/>  
    </antcall>
</if>
  </target>
<!--Move Dir-->
  <target name="moveDir" if="present">
    <echo>Make sure the dirs and files are not locked. And the tridion
services are stoped.</echo>
    <echo>Move ${oldDir} to ${moveToDir}</echo>
    <move todir="${moveToDir}">
      <fileset dir="${oldDir}" defaultexcludes="false"/>
    </move>
  </target>



<!--========================================WITHOUT IF
==================================================-->

<!--==========================-->
<!--=Rename old source folder=-->
<!--==========================-->
  <target name="renameSourceFolder" depends="init" description="Rename old
source folder">
    <property name="moveToSrcDir"
location="${oldSrcDir}_${DSTAMP}-${TSTAMP}"/>
    <property name="moveToSrcIntegrationDir"
location="${oldSrcIntegrationDir}_${DSTAMP}-${TSTAMP}"/>
    <property name="moveToTDSCollectionDir"
location="${oldTDSCollectionDir}_${DSTAMP}-${TSTAMP}"/>
    <available file="${oldSrcDir}" type="dir" property="oldSrcDir.present"/>
    <available file="${oldSrcIntegrationDir}" type="dir"
property="oldSrcIntegrationDir.present"/>
    <available file="${oldTDSCollectionDir}" type="dir"
property="oldTDSCollectionDir.present"/>
 
    <antcall target="moveRouter">
       <param name="checkPresent" value="${oldSrcDir.present}"/>  
       <param name="moveToDir" value="${moveToSrcDir}"/>  
       <param name="oldDir" value="${oldSrcDir}"/>  
    </antcall>
    <antcall target="moveRouter">
       <param name="checkPresent" value="${oldSrcDir.present}"/>  
       <param name="moveToDir" value="${moveToSrcIntegrationDir}"/>  
       <param name="oldDir" value="${oldSrcIntegrationDir}"/>  
    </antcall>

    <antcall target="moveRouter">
       <param name="checkPresent" value="${oldTDSCollectionDir.present}"/>  
       <param name="moveToDir" value="${moveToTDSCollectionDir}"/>  
       <param name="oldDir" value="${oldTDSCollectionDir}"/>  
    </antcall>

  </target>

<!--Move Dir Router-->
  <target name="moveRouter">
    <condition property="present">
      <istrue value="${checkPresent}" />
    </condition>
    <antcall target="moveDir"/>
  </target>
  
<!--Move Dir-->
  <target name="moveDir" if="present">
    <echo>Make sure the dirs and files are not locked. And the tridion
services are stoped.</echo>
    <echo>Move ${oldDir} to ${moveToDir}</echo>
    <move todir="${moveToDir}">
      <fileset dir="${oldDir}" defaultexcludes="false"/>
    </move>
  </target>

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