ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael Sunde" <msu...@actional.com>
Subject RE: is it possible to create targets dynamically?
Date Fri, 16 Jan 2004 21:22:32 GMT
Yeah, I thought of that, but then I can't call the target directly from the command line:
	ant dynamic

Thanks,
Michael

> -----Original Message-----
> From: CONANT,PATRICK (HP-FtCollins,ex1) [mailto:patrick.conant@hp.com]
> Sent: Friday, January 16, 2004 4:19 PM
> To: 'Ant Users List'
> Subject: RE: is it possible to create targets dynamically?
> 
> 
> You might just call a single target with different parameters.  For
> instance:
> 
> 
> <project name="test" default="all" basedir=".">
>   <target name="all">
>     <antcall target="dowork">
>       <param name="path" value="path1"/>
>     </antcall>
>     <antcall target="dowork">
>       <param name="path" value="path2"/>
>     </antcall>
>     <antcall target="dowork">
>       <param name="path" value="path3"/>
>     </antcall>
>   </target>
> 
>   <target name="dowork">
>     <!-- the real work goes here. -->
>   </target>
> </project>
> 
> --p.
> 
> 
> -----Original Message-----
> From: Michael Sunde [mailto:msunde@actional.com] 
> Sent: Friday, January 16, 2004 2:11 PM
> To: Ant Users List
> Subject: is it possible to create targets dynamically?
> 
> 
> Hi,
>  
> When looking at my build.xml file, there are several targets 
> that are almost
> identical. The main difference between them is the name of 
> the target and a
> path. Is it possible to create a target dynamically. I tried 
> using macrodef
> in ant 1.6 but that did not work:
>  
> <project name="test" default="all" basedir=".">
> <macrodef name="echoTarget">
>    <attribute name="name" />
>    <sequential>
>       <target name="@{name}">
>          <echo>@{name} target executed.</echo>
>          <!-- the real work goes here. -->
>       </target>
>    </sequential>
> </macrodef>
> <echoTarget name="dynamic"/>
> <target name="all" depends="dynamic"/>
> </project>
> 
> Error:
> E:\builds\build.xml:11: Following error occured while 
> executing this line
> E:\builds\build.xml:5: Could not create task or type of type: target.
>  
> From the command line, I would like to be able to do:
>    ant dynamic
>  
> The only way I can think of doing it is to run an xslt on the 
> build file to
> generate all the targets. Is there another cleaner/simpler solution?
>  
> Thanks,
> Michael
>  
> 
> ---------------------------------------------------------------------
> 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