// Write master Ant build file
saveFile("build.xml");
// Execute the Ant build file
Project project = new Project();
project.init();
project.setUserProperty("ant.file", new File(dir, "build.xml").getAbsolutePath());
ProjectHelper.configureProject(project, new File(dir, "build.xml"));
project.setBaseDir(dir);
// Configure logging verbosity
BuildLogger logger = new DefaultLogger();
logger.setMessageOutputLevel(this.verbose ? Project.MSG_VERBOSE
: this.quiet ? Project.MSG_WARN : Project.MSG_INFO);
logger.setOutputPrintStream(System.out);
logger.setErrorPrintStream(System.err);
project.addBuildListener(logger);
// Set properties
project.setUserProperty("ivy.packager.organisation", ""
+ this.mr.getModuleId().getOrganisation());
project.setUserProperty("ivy.packager.module", "" + this.mr.getModuleId().getName());
project.setUserProperty("ivy.packager.revision", "" + this.mr.getRevision());
project.setUserProperty("ivy.packager.branch", "" + this.mr.getBranch());
if (this.resourceCache != null) {
project.setUserProperty("ivy.packager.resourceCache",
"" + this.resourceCache.getCanonicalPath());
}
if (this.resourceURL != null) {
project.setUserProperty("ivy.packager.resourceURL", "" + getResourceURL());
}
if (this.validate) {
project.setUserProperty("ivy.packager.validate", "true");
}
project.setUserProperty("ivy.packager.restricted", "" + this.restricted);
project.setUserProperty("ivy.packager.quiet", String.valueOf(quiet));
if (properties != null) {
for (Iterator it = properties.entrySet().iterator(); it.hasNext();) {
Entry entry = (Entry) it.next();
project.setUserProperty((String) entry.getKey(), (String) entry.getValue());
}
}
// Execute task
Message.verbose("performing packager resolver build in " + this.dir);
try {
project.executeTarget("build");
this.built = true;
} catch (BuildException e) {
Message.verbose("packager resolver build failed: " + e);
throw e;
}