0

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 ?

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.