Ant中java任务使用命令行传参数

来源:互联网 发布:华为2012实验室 知乎 编辑:程序博客网 时间:2024/06/06 01:03
目前需要使用ant来执行一个含有main方法的class文件,并且需要通过命令来行传两个参数(start和end)到main方法。
<target name="gsp" depends="compile" description="generator structure pictures">  <echo message="----------- Generator structure pictures ------------" />  <property name="start" value="1" />  <property name="end" value="892046" />   <java fork="true" classname="com.founder.cst.system.StructureImageGenerator">    <arg value="${start}"/>    <arg value="${end}"/>    <classpath path="${build.dir}/classes"/>    <classpath refid="classpath" />   </java>   <echo message="----------- End------------" /> </target>
这样执行ant gsp -Dstart=10 -Dend=20 就可以把10和20传到main方法中了,最好设置默认值。

原创粉丝点击