Reputation: 137
I want to execute an antscript from java program with arguments, example: ant -f myantscript.xml -dir \my\path\dir .I am able to run without arguments like this
File buildFile = new File("build.xml");
Project p = new Project();
p.setUserProperty("ant.xml", buildFile.getAbsolutePath());
p.init();
ProjectHelper helper = ProjectHelper.getProjectHelper();
p.addReference("ant.projectHelper", helper);
helper.parse(p, buildFile);
p.executeTarget(p.getDefaultTarget());
which function can i use to set arguments ?
Upvotes: 0
Views: 49
Reputation: 1239
You can set it as a system property
Properties props = System.getProperties();
props.setProperty("build.dir", "build");
Or
System.setProperty("build.dir", "build");
I hope this could help.
Upvotes: 1