consoleLogger.setOutputPrintStream(System.out);
consoleLogger.setMessageOutputLevel(Project.MSG_INFO);
// execute ant build
final File buildFile = new File(buildFileStr);
final Project p = new Project();
// p.setCoreLoader(getClass().getClassLoader());
p.addBuildListener(consoleLogger);
p.setUserProperty("ant.file", buildFile.getAbsolutePath());
p.setProperty(BUILD_CLASSPATH, buildClasspathStr);
p.setProperty(BUILD_VERBOSE, buildVerboseStr);
p.init();
final ProjectHelper helper = ProjectHelper.getProjectHelper();
p.addReference("ant.projectHelper", helper);
helper.parse(p, buildFile);
final String[] buildTargets = buildTargetStr == null
|| buildTargetStr.isEmpty() ? new String[] { p
.getDefaultTarget() } : buildTargetStr.split(",");
for (final String t : buildTargets) {
if (!t.trim().isEmpty()) {
System.out.println();
if (Boolean.parseBoolean(buildVerboseStr)) {
System.out.println("Executing Target: " + t);
}
p.executeTarget(t.trim());
}
}
}