use of org.apache.maven.shared.invoker.InvocationRequest in project dspot by STAMP-project.
the class MavenAutomaticBuilder method _runGoals.
private int _runGoals(boolean specificPom, final String pomPathname, String... goals) {
InvocationRequest request = new DefaultInvocationRequest();
request.setGoals(Arrays.asList(goals));
request.setPomFile(new File(pomPathname));
request.setJavaHome(new File(System.getProperty("java.home")));
if (specificPom) {
request.setProfiles(Collections.singletonList(DSpotPOMCreator.PROFILE_ID));
}
Properties properties = new Properties();
properties.setProperty("enforcer.skip", "true");
properties.setProperty("checkstyle.skip", "true");
properties.setProperty("cobertura.skip", "true");
properties.setProperty("skipITs", "true");
properties.setProperty("rat.skip", "true");
properties.setProperty("license.skip", "true");
properties.setProperty("findbugs.skip", "true");
properties.setProperty("gpg.skip", "true");
request.setProperties(properties);
request.setInputStream(new NullInputStream(1000));
Invoker invoker = new DefaultInvoker();
LOGGER.info("Using {} for maven home", mavenHome);
invoker.setMavenHome(new File(mavenHome));
LOGGER.info(String.format("run maven: %s/bin/mvn %s", mavenHome, String.join(" ", goals)));
if (DSpotState.verbose) {
invoker.setOutputHandler(System.out::println);
invoker.setErrorHandler(System.err::println);
} else {
invoker.setOutputHandler(null);
invoker.setErrorHandler(null);
}
try {
return invoker.execute(request).getExitCode();
} catch (MavenInvocationException e) {
throw new RuntimeException(e);
}
}
Aggregations