in tools/erlanalysis/src/main/java/org/apache/dubbo/erlang/analysis/utils/MavenJarUtil.java [45:85]
public boolean copyDependence() {
String mvn_home = System.getenv("MAVEN_HOME");
this.rootDir = genProjectDir(System.getProperty("project_save_dir", System.getProperty("user.dir") + File.separator + "mavenDown"));
if (rootDir == null) {
return false;
}
log.info("down load lib jar dir:" + rootDir);
String pomPathJar = genPomFile(this.rootDir, "jar");
InvocationRequest request = new DefaultInvocationRequest();
request.setPomFile(new File(pomPathJar));
request.setGoals(Collections.singletonList("compile"));
Invoker invoker = new DefaultInvoker();
try {
if (mvn_home != null) {
log.info("use MAVEN_HOME:" + mvn_home);
invoker.setMavenHome(new File(mvn_home));
}
invoker.setWorkingDirectory(new File(rootDir));
InvocationResult result = invoker.execute(request);
if (result.getExitCode() != 0) {
String pomPathWar = genPomFile(this.rootDir, "war");
InvocationRequest requestWar = new DefaultInvocationRequest();
requestWar.setPomFile(new File(pomPathWar));
requestWar.setGoals(Collections.singletonList("compile"));
invoker.setWorkingDirectory(new File(rootDir));
InvocationResult resultWar = invoker.execute(requestWar);
if (resultWar.getExitCode() != 0) {
log.error("mvn run result exception:" + resultWar.getExecutionException());
return false;
}
}
} catch (MavenInvocationException e) {
e.printStackTrace();
}
return true;
}