Hello,
I would like to call build.xml file from a Java program. I am new Ant user. I found a sample code below:
File buildFile = new File("build.xml");
Project p = new Project();
p.setUserProperty("ant.file", buildFile.getAbsolutePath());
DefaultLogger consoleLogger = new DefaultLogger();
consoleLogger.setErrorPrintStream(System.err);
consoleLogger.setOutputPrintStream(System.out);
consoleLogger.setMessageOutputLevel(Project.MSG_INFO);
p.addBuildListener(consoleLogger);
try {
p.fireBuildStarted();
p.init();
ProjectHelper helper = ProjectHelper.getProjectHelper();
p.addReference("ant.projectHelper", helper);
helper.parse(p, buildFile);
p.executeTarget(p.getDefaultTarget());
p.fireBuildFinished(null);
} catch (BuildException e) {
p.fireBuildFinished(e);
}
But it gives me an error message as
BUILD FAILED
F:\workspace\Eclipse-Playground\de.itesys.xslt.docbook\build.xml:7: Cannot find F:\workspace\Eclipse-Playground\de.itesys.xslt.docbook\${net.sourceforge.dep4e.resources}\ant\docbook_5-0.xml imported from F:\workspace\Eclipse-Playground\de.itesys.xslt.docbook\build.xml
Total time: 0 seconds
Therefore I would like to know what is the right way to call build.xml file. Thank you.
In the attachment you can find an example project from DEP4E.