ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter Reilly <>
Subject Re: Multiple directory existence checking
Date Tue, 11 May 2004 17:23:23 GMT
Dominique Devienne wrote:

>>From: Matt Benson []
>>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=":"/>
        <ac:for list="@{subdirs}" delimiter="@{delimiter}" param="dir">
            <condition property="@{property}">
                <available file="@{root}/@{dir}" type="dir"/>
    <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">
      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;

    <condition property="all.dirs.present">
      <allpresent root="." subdirs="a:b:c"/>
    <echo>all.dirs.present : ${all.dirs.present}</echo>

    <condition property="upper.dirs.present">
      <allpresent root=".." subdirs="for"/>
    <echo>upper.dirs.present : ${upper.dirs.present}</echo>


>To unsubscribe, e-mail:
>For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message