* @param build specify whether make the build (compile, jar etc.) or not
* @param pom the pom file
* @throws Exception the exception
*/
public void install(String basedir, boolean build, File pom) throws Exception {
Model model = pomReader.readModel(pom, true);
File jarFileToInstall;
if(build) {
jarFileToInstall = buildProject(model);
}
else {
String artifactId = model.getArtifactId();
File buildDirFile = new File(basedir, "target");
String buildDir = buildDirFile.getAbsolutePath();
jarFileToInstall = new File(buildDir, artifactId + ".jar");
}
install(model, pom, jarFileToInstall);
String type = model.getPackaging();
if (type.equalsIgnoreCase("pom")) {
for (Object o : model.getModules()) {
String module = (String) o;
File modulePom = new File(pom.getParent(), module + File.separatorChar + "pom.xml");
Model moduleReader = pomReader.readModel(modulePom, false);
installPomFile(moduleReader, modulePom);
}
}
}