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

来源:互联网 发布:csp绘画软件下载 编辑:程序博客网 时间:2024/06/04 22:31
目前需要使用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方法中了,最好设置默认值。

子曰:危邦不入,乱邦不居。天下有道则见,无道则隐。
原创粉丝点击