One method could be to:
(1) Define a <path id="path.javac"> with nested <fileset> that defines the
set of files to your liking.
(2) Convert the path to a property string: <property
name="path.javac.files" refid="path.javac"/>
(3) The file count is the number of path separators + 1. Use a <script>
tag:
<script language="javascript"> <![CDATA[
var path = project.getProperty("path.javac.files");
var count = 0;
if (path.length > 0) {
for (var i = 0; i < path.length; i++) {
if (path.charAt(i) == ':') { // FIXME for portability
count++;
}
}
count++;
}
project.setProperty("path.javac.count", count);
]]> </script>
Note I just hacked out the javascript; syntax and logic may be incorrect,
but you get the idea...
Paul
>
> Hi,
>
> I'ld quite like to have a target which simply produces a count of the
> number of .java files in my project.
>
> Ideally, this would be a simple 'count' task which takes a
> fileset,patternset
> or something similar to the javac task and then sets a
> property value to the
> result. I'ld like then to be able to echo out some text
> displaying this value.
>
> The echo requirement is because I have a large build
> involving many subprojects
> and generally run ant with the -quiet option, to provide
> neater more compact
> output.
>
> I've seen previous posts which have found a solution using OS specific
> calls but I'm not going to go down that route.
>
> Any ideas ?
>
> Gareth
>
>
>
> --
>
> Diese E-Mail enth�lt vertrauliche und/oder rechtlich
> gesch�tzte Informationen. Wenn Sie nicht der richtige
> Adressat sind oder diese E-Mail irrt�mlich erhalten haben,
> informieren Sie bitte sofort den Absender und vernichten Sie
> diese Mail. Das unerlaubte Kopieren sowie die unbefugte
> Weitergabe dieser Mail ist nicht gestattet.
>
> This e-mail may contain confidential and/or privileged
> information. If you are not the intended recipient (or have
> received this e-mail in error) please notify the sender
> immediately and destroy this e-mail. Any unauthorized
> copying, disclosure or distribution of the material in this
> e-mail is strictly forbidden.
>
>
>
> --
> To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>