ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <Jan.Mate...@rzf.fin-nrw.de>
Subject AW: Call a target with parameter?
Date Wed, 08 Aug 2007 10:17:44 GMT
<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@gmail.com] 
>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@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