Java Mailing List Archive

http://www.ant-tasks.com/

Apache Ant Archive

» Ant Users List
» Ant Developers List
Invoking a target (Ant 1.7) in a loop (Ant-Contrib)

Invoking a target (Ant 1.7) in a loop (Ant-Contrib)

2007-01-16       - By Rebo, Alex
Reply:     1     2     3     4     5     6     7     8     9     10     >>  

Hello!

In attempt to compute checksums for all files in a directory I wrote this:

<fileset id="myLibs" dir="${extention}">
   <include name="*.jar"/>
</fileset>

.....

<target name="thisTargetName">
   <foreach target="computeCheckSum" param="fileToWorkOn"
inheritall="true">
       <path>
           <fileset refid="myLibs" />
       </path>
   </foreach>
</target>

....

<target name="computeCheckSum">
   <checksum file="${fileToWorkOn}" algorithm="MD5" />
   <echo>
       Created checksum file for ${fileToWorkOn}.
   </echo>
</target>

OK. It's, probably, the worst Ant you ever seen. (BTW, any comments on how
to improve it
are welcome). But it works ... until you ask it to become verbose.

Here what it does:

 [antcall] calling target(s) [computeCheckSum] in build file
C:\Devel\RAD\RADWor
kspace_Sample\ConfigureServer\build.xml
parsing buildfile C:\Devel\RAD\RADWorkspace_Sample\ConfigureServer\build.xml
wit
h URI = file:/C:/Devel/RAD/RADWorkspace_Sample/ConfigureServer/build.xml
Project base dir set to: C:\Devel\RAD\RADWorkspace_Sample\ConfigureServer
parsing buildfile
jar:file:/C:/Java/Apache/Ant/ant-contrib/ant-contrib-1.0b3.jar
!/net/sf/antcontrib/antlib.xml with URI =
jar:file:/C:/Java/Apache/Ant/ant-contr
ib/ant-contrib-1.0b3.jar!/net/sf/antcontrib/antlib.xml
Trying to override old definition of task propertycopy
Trying to override old definition of task shellscript

.....

Trying to override old definition of task headMethod
Trying to override old definition of task importurl
[property] Loading Environment env.
[property] Loading
C:\Devel\RAD\RADWorkspace_Sample\ConfigureServer\build.prope
rties
 [antcall] Entering
C:\Devel\RAD\RADWorkspace_Sample\ConfigureServer\build.xml.
..
Build sequence for target(s) `computeCheckSum is [computeCheckSum]
Complete build sequence is [computeCheckSum, determineEnv, selfCheck,
destCheck,
copy, configure, test, main, , verifyCheckSum]

computeCheckSum:
 [antcall] Exiting
C:\Devel\RAD\RADWorkspace_Sample\ConfigureServer\build.xml.
 [antcall] calling target(s) [computeCheckSum] in build file
C:\Devel\RAD\RADWor
kspace_Sample\ConfigureServer\build.xml
parsing buildfile C:\Devel\RAD\RADWorkspace_Sample\ConfigureServer\build.xml
wit
h URI = file:/C:/Devel/RAD/RADWorkspace_Sample/ConfigureServer/build.xml
Project base dir set to: C:\Devel\RAD\RADWorkspace_Sample\ConfigureServer
parsing buildfile
jar:file:/C:/Java/Apache/Ant/ant-contrib/ant-contrib-1.0b3.jar
!/net/sf/antcontrib/antlib.xml with URI =
jar:file:/C:/Java/Apache/Ant/ant-contr
ib/ant-contrib-1.0b3.jar!/net/sf/antcontrib/antlib.xml
Trying to override old definition of task propertycopy
Trying to override old definition of task shellscript

...

Trying to override old definition of task headMethod
Trying to override old definition of task importurl
[property] Loading Environment env.
[property] Loading
C:\Devel\RAD\RADWorkspace_Sample\ConfigureServer\build.prope
rties
 [antcall] Entering
C:\Devel\RAD\RADWorkspace_Sample\ConfigureServer\build.xml.

Looks like it's calling itself via [antcall]. Is suppose to do that when
target is invoked in a loop?
Or I'm doing smth awfully "smart"?



©2008 ant-tasks.com - Jax Systems, LLC, U.S.A.