ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter Reilly <peter.rei...@corvil.com>
Subject Re: Multiple directory existence checking
Date Wed, 12 May 2004 10:04:12 GMT
You need to get ant-contrib(-0.6).jar from the
antcontrib site:
http://ant-contrib.sourceforge.net/ is the site:
http://sourceforge.net/project/showfiles.php?group_id=36177 is the 
downloads page.
Download ant-contrib-0.6.tar.bz2 or ant-contrib-0.6.zip
and extract the ant-contrib-0.6.jar file.
Place the ant-contrib-0.6.jar into $ANT_HOME/lib or into ~/.ant/lib.
The namespace "antlib:net.sf.antcontrib" will then cause the tasks from the
ant-contrib jar to be loaded.

The project element should declare the namepace:

<project default="target" xmlns:ac="antlib:net.sf.antcontrib">
    <target name="target">
       <ac:for list="1,2,4,8" param="number">
          <ac:sequential>
             <echo>Number is @{number}</echo>
          </ac:sequential>
      </ac:for>
   </target>
</project>

Peter

Noel Sebastien (BIL) wrote:

>Maybe my question is stupid, but I need to understand and make the example work here...
>
>In the first example below, my ant command failed on the namespace ac... :
>
> <ac:for li...
>
>I just installed Ant 1.6.1 (supporting namespace). But how to declare your ac namespace
and where ? Is it antcontrib ? and is there something (a additional jar)
>to install on 1.6.1 ?
>
>Thank you.
>
>-----Original Message-----
>From: Peter Reilly [mailto:peter.reilly@corvil.com]
>Sent: mardi 11 mai 2004 19:23
>To: Ant Users List
>Subject: Re: Multiple directory existence checking
>
>
>Dominique Devienne wrote:
>
>  
>
>>>From: Matt Benson [mailto:gudnabrsam@yahoo.com]
>>>
>>>Okay, gotta get my $0.02 in...
>>>
>>>Using pure Ant, since you have said that all
>>>directories share a parent, you should be able to do
>>>what you want using:
>>>
>>>a list of the subdirectories
>>>one or more <dirset>s
>>>one or more <pathconvert> invocations
>>>the <equals> condition, possibly
>>>   
>>>
>>>      
>>>
>>Sounds like everyone's enjoying that one ;-)
>>
>>Game to try it without <script> ;-)))
>>
>>I actually think it's not doable with pure Ant (no <script>),
>>but I could be wrong....
>>
>>I think Peter's solution is hard to top, and the easiest. --DD
>> 
>>
>>    
>>
>One could put it in an macrodef:
>    <macrodef name="checknotallpresent">
>      <attribute name="property"/>
>      <attribute name="subdirs"/>
>      <attribute name="root"/>
>      <attribute name="delimiter" default=":"/>
>      <sequential>
>        <ac:for list="@{subdirs}" delimiter="@{delimiter}" param="dir">
>          <ac:sequential>
>            <condition property="@{property}">
>              <not>
>                <available file="@{root}/@{dir}" type="dir"/>
>              </not>
>            </condition>
>          </ac:sequential>
>        </ac:for>
>      </sequential>
>    </macrodef>
>    <checknotallpresent property="notall.present"
>                        root="." subdirs="a:b:c"/>
>    <echo>notall.present : ${notall.present}</echo>
>    <checknotallpresent property="upper.notall.present"
>                        root=".." subdirs="for"/>
>    <echo>upper.notall.present : ${upper.notall.present}</echo>
>
>or use scripttypedef:
>
>    <ae:scripttypedef name="allpresent" language="groovy">
>      import org.apache.tools.ant.taskdefs.condition.Condition
>      import java.io.File
>      public class NotAllPresent implements Condition {
>         File root
>         String subdirs
>         public boolean eval() {
>            for (file in subdirs.split(":")) {
>                if (!(new File(root, file).exists())) {
>                    return false;
>                }
>            }
>            return true;
>         }
>      }
>      NotAllPresent
>    </ae:scripttypedef>
>
>    <condition property="all.dirs.present">
>      <allpresent root="." subdirs="a:b:c"/>
>    </condition>
>    <echo>all.dirs.present : ${all.dirs.present}</echo>
>
>    <condition property="upper.dirs.present">
>      <allpresent root=".." subdirs="for"/>
>    </condition>
>    <echo>upper.dirs.present : ${upper.dirs.present}</echo>
>
>Peter
>
>  
>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>>For additional commands, e-mail: user-help@ant.apache.org
>>
>>
>>
>> 
>>
>>    
>>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>For additional commands, e-mail: user-help@ant.apache.org
>
>
>
>---------------------
>An electronic message is not binding on its sender.  
>Any message referring to a binding engagement must be confirmed in writing and duly signed.
>---------------------
>
>
>
>---------------------
>An electronic message is not binding on its sender.  
>Any message referring to a binding engagement must be confirmed in writing and duly signed.
>---------------------
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>For additional commands, e-mail: user-help@ant.apache.org
>
>
>
>  
>


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


Mime
View raw message