ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Fermin Da Costa Gomez <f.dacost...@gmail.com>
Subject Re: Counting files in a dir
Date Tue, 05 Apr 2005 21:15:00 GMT
Matt Benson wrote:

>--- Fermin Da Costa Gomez <f.dacosta.g@gmail.com>
>wrote:
>  
>
>>Hi,
>>
>>What would be the best way to do the following:
>>1. Going into a directory (this is ok)
>>2. Counting the number of files of type x (getting
>>files is ok, *counting* is an 
>>issue)
>>    
>>
>
>With Ant 1.6.3 (now in beta) you could do this:
>
><pathconvert property="foo" pathsep="">
>  <path>
>    <fileset dir="foo" includes="*.foo" />
>  </path>
>  <mergemapper to="-" />
></pathconvert>
>
><length string="${foo}" property="foo.length" />
>
>(look for a cooler way to do this in Ant 1.7!)
>  
>
This is alread pretty decent. Thx, much appreciated.

>>3. Depending on the count do something (break out of
>>the target)
>>
>>Items 2. and 3. are bugging me somewhat (esp the
>>counting bit in 2).
>>Does anybody have a suggestion as to how i can
>>accomplish this?
>>    
>>
>
>3. depends on what the comparison is... rather than
>break out of a target, however, you are probably
>better off to decompose your build so that the part
>you want to skip by breaking out is in its own target,
>which depends on a target that does this count-check. 
>Most likely you will test its results with another
>condition to set a property (or not), and whether this
>property is set will determine whether the final
>target is run.  Under what circumstances do you NOT
>want to continue, after having counted the files? 
>What actions are you trying to avoid?
>  
>
Maybe i did not explain my requirement well enough.
The thing is that i am looping through a series of dirs and *if* they 
contain 1 or more TestStubs they need to be put in a suite.
...
<foreach list="${dirs}" target="-unitTestSuite" param="dir" 
delimiter="${path.separator}" />
...

<target name="-unitTestSuite">
 <if>
  .. Check how many files are stubs .. 
  <equals arg1="noOfFiles" arg2="0" />
   <then>
    <echo message="Source dir not to be included" />
    .. and go back to the caller, *no processing*
   </then>
   <else>Do some processing</else>
  </if>
</target>

The above snip is what i have in mind. Does it look sensible or am i 
missing some significant ant thing ;-)

tia,

Fermin DCG


>-Matt
>  
>
>>tia,
>>
>>Fermin DCG
>>
>>
>>    
>>
>---------------------------------------------------------------------
>  
>
>>To unsubscribe, e-mail:
>>user-unsubscribe@ant.apache.org
>>For additional commands, e-mail:
>>user-help@ant.apache.org
>>
>>
>>    
>>
>
>
>		
>__________________________________ 
>Yahoo! Messenger 
>Show us what our next emoticon should look like. Join the fun. 
>http://www.advision.webevents.yahoo.com/emoticontest
>
>---------------------------------------------------------------------
>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