Java Mailing List Archive

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

Apache Ant Archive

» Ant Users List
» Ant Developers List
AW: Call a target with parameter?

AW: Call a target with parameter?

2007-08-08       - By Jan.Materne@(protected)

<target name="run" if="class">
   <java classname="${class}"/>
</target>

$ ant -Dclass=MyClass
$ ant -Dclass=YourClass
$ ant -Dclass=HisClass


or


<macrodef name="run">
   <attribute name="class" default="MyClass"/>
   <sequential>
       <java classname="@{class}"/>
   </sequential>
</macrodef>
<target name="run-a">
   <run/>
</target>
<target name="run-b">
   <run class="YourClass"/>
</target>
<target name="run-C">
   <run class="HisClass"/>
</target>



or

<target name="-run">
   <java classname="${class}"/>
</target>
<target name="run-a">
   <antcall target="-run">
       <param key="class" value="MyClass"/>
   </antcall>
</target>
...


Jan




>-----Urspr?ngliche Nachricht-----
>Von: hezjing [mailto:hezjing@(protected)]
>Gesendet: Mittwoch, 8. August 2007 12:08
>An: ant-users
>Betreff: Call a target with parameter?
>
>Hi!
>
>My build.xml contains few targets to run different main classes,
>
>  <target name="run-a">
>    <java classname="MyClass" />
>  </target>
>  <target name="run-b">
>    <java classname="YourClass" />
>  </target>
>  <target name="run-c">
>    <java classname="HisClass" />
>  </target>
>
>
>Can I simplify this by defining one target with <java> and the common
>classpath and system properties configuration, and then call this
>target with different class names?
>
>
>--
>
>Hez
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@(protected)
>For additional commands, e-mail: user-help@(protected)
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@(protected)
For additional commands, e-mail: user-help@(protected)


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