Possible Duplicate:
Use Ant for running program with command line arguments
I have written a java program that gets as command line arguments several file names (that are inputted into String[] args
array of the main.
Now I need to write an Ant build file.
How do I make this command:
ant run SampleFile1.txt SampleFile2.txt ...
Get those arguments and pass them to my main?
Here's my sample Ant file:
<?xml version="1.0" ?>
<project name="MyProgram" default="main">
<property name="src.dir" value="src"/>
<property name="build.dir" value="build"/>
<property name="classes.dir" value="${build.dir}/classes"/>
<property name="jar.dir" value="${build.dir}/jar"/>
<property name="main-class" value="MyProgram.MainClass"/>
<target name="clean">
<delete dir="${build.dir}"/>
</target>
<target name="compile">
<mkdir dir="${classes.dir}"/>
<javac srcdir="${src.dir}" destdir="${classes.dir}"/>
</target>
<target name="jar" depends="compile">
<mkdir dir="${jar.dir}"/>
<jar destfile="${jar.dir}/${ant.project.name}.jar" basedir="${classes.dir}">
<manifest>
<attribute name="Main-Class" value="${main-class}"/>
</manifest>
</jar>
</target>
<target name="run" depends="jar">
<java jar="${jar.dir}/${ant.project.name}.jar" fork="true">
//now when I run it here, I want it to get the arguments I input when I do ant run. for example: ant run file1.txt, file2.txt <- I want those to go to my String[] args of the main
</java>
</target>
<target name="clean-build" depends="clean,jar"/>
<target name="main" depends="clean,run"/>