Reputation: 801
I have two projects:
project A: (Java) &
project B: (ANT-Java)
I want to build project B from project A. Actually Project A feeds a file to project B. please suggest me a way to do this.
Upvotes: 1
Views: 51
Reputation: 59
If you want to call ANT from Java without doing it by running an external command (calling ant), you could include ant runtime (ant.jar, download at apache ant webpage) in your project A and execute any build target from your B project.
Example:
File buildFile = new File("build.xml");
Project p = new Project();
p.setUserProperty("ant.file", buildFile.getAbsolutePath());
p.init();
ProjectHelper helper = ProjectHelper.getProjectHelper();
p.addReference("ant.projectHelper", helper);
helper.parse(p, buildFile);
p.executeTarget(p.getDefaultTarget());
You could check this article. It show how to manage return results and generated log. Hope this helps.
Upvotes: 1