FileUtils futils = FileUtils.getFileUtils();
configFile = futils.resolveFile(basedir, config);
}
if (!configFile.exists()) {
throw new MoxieException(MessageFormat.format("Failed to find Moxie descriptor {0}", configFile));
}
// parse the config files and Moxie settings
build = new Build(configFile, basedir);
BuildConfig buildConfig = build.getConfig();
buildConfig.setVerbose(isVerbose());
// set any external properties into the project
for (Map.Entry<String, String> entry : buildConfig.getExternalProperties().entrySet()) {
getConsole().debug("setting external property {0} = {1}", entry.getKey(), entry.getValue());
getProject().setProperty(entry.getKey(), entry.getValue());
}
build.getPom().setAntProperties(antProperties);
// add a reference to the full build object
getProject().addReference(Key.build.referenceId(), build);
// output the build info
build.describe();
build.setup();
if (isVerbose()) {
getConsole().separator();
getConsole().log(getProject().getProperty("ant.version"));
getConsole().log("Moxie Build Toolkit version " + Toolkit.getVersion() + " compiled on " + Toolkit.getBuildDate());
}
Pom pom = build.getPom();
// push all pom properties into project
Map<String,String> properties = pom.getProperties();
for (Map.Entry<String, String> entry : properties.entrySet()) {
getProject().setProperty(entry.getKey(), entry.getValue());
}
if (isVerbose()) {
getConsole().separator();
getConsole().log("project properties");
}
setProjectProperty(Key.name, pom.name);
setProjectProperty(Key.description, pom.description);
setProjectProperty(Key.groupId, pom.groupId);
setProjectProperty(Key.artifactId, pom.artifactId);
setProjectProperty(Key.version, pom.version);
setProjectProperty(Key.organization, pom.organization);
setProjectProperty(Key.organizationUrl, pom.organizationUrl);
setProjectProperty(Key.issuesUrl, pom.issuesUrl);
setProjectProperty(Key.forumUrl, pom.forumUrl);
setProjectProperty(Key.socialNetworkUrl, pom.socialNetworkUrl);
setProjectProperty(Key.blogUrl, pom.blogUrl);
setProjectProperty(Key.ciUrl, pom.ciUrl);
setProjectProperty(Key.mavenUrl, pom.mavenUrl);
setProjectProperty(Key.url, pom.url);
if (pom.scm != null) {
setProjectProperty(Key.scmUrl, pom.scm.url);
}
setProjectProperty(Key.mainclass, buildConfig.getProjectConfig().getMainclass());
setProjectProperty(Key.releaseVersion, buildConfig.getPom().releaseVersion);
setProjectProperty(Key.releaseDate, build.getReleaseDateString());
setProjectProperty(Key.buildDate, build.getBuildDateString());
setProjectProperty(Key.buildTimestamp, build.getBuildTimestamp());
setReference(Key.buildDate, build.getBuildDate());
setReference(Key.releaseDate, build.getReleaseDate());
setProjectProperty(Key.outputDirectory, buildConfig.getOutputDirectory(null).toString());
setProjectProperty(Key.compileOutputDirectory, buildConfig.getOutputDirectory(Scope.compile).toString());
setProjectProperty(Key.testOutputDirectory, buildConfig.getOutputDirectory(Scope.test).toString());
setProjectProperty(Key.targetDirectory, buildConfig.getTargetDirectory().toString());
setProjectProperty(Key.reportTargetDirectory, buildConfig.getReportsTargetDirectory().toString());
setProjectProperty(Key.javadocTargetDirectory, buildConfig.getJavadocTargetDirectory().toString());
setProjectProperty(Key.siteSourceDirectory, buildConfig.getSiteSourceDirectory().toString());
setProjectProperty(Key.siteTargetDirectory, buildConfig.getSiteTargetDirectory().toString());
if (isVerbose()) {
getConsole().separator();
getConsole().log("project path properties");
}
setSourcepath(Key.compileSourcePath, buildConfig, Scope.compile);
setSourcepath(Key.testSourcePath, buildConfig, Scope.test);
setClasspath(Key.compileOutputPath, build, Scope.compile, false, false);
setClasspath(Key.testOutputPath, build, Scope.test, true, false);
setResourcepath(Key.compileResourcePath, buildConfig, Scope.compile);
setResourcepath(Key.runtimeResourcePath, buildConfig, Scope.runtime);
setResourcepath(Key.testResourcePath, buildConfig, Scope.test);
setDependencypath(Key.compileDependencyPath, build, Scope.compile);
setDependencypath(Key.runtimeDependencyPath, build, Scope.runtime);
setDependencypath(Key.testDependencyPath, build, Scope.test);
setClasspath(Key.compileClasspath, build, Scope.compile, false, true);
setClasspath(Key.runtimeClasspath, build, Scope.runtime, true, true);
setClasspath(Key.testClasspath, build, Scope.test, true, true);
setClasspath(Key.buildClasspath, build, Scope.build, false, true);
updateExecutionClasspath();
} catch (Exception e) {
throw new MoxieException(e);
}
}