use of org.appformer.maven.integration.embedder.MavenRequest in project kie-wb-common by kiegroup.
the class MavenBuildExecutor method executeMaven.
public static void executeMaven(final File pom, final PrintStream stdout, final PrintStream stderr, final Properties properties, final String... goals) {
final PrintStream oldout = System.out;
final PrintStream olderr = System.err;
final Properties oldProperties = System.getProperties();
if (properties != null) {
properties.keySet().forEach((o) -> {
if (properties.getProperty((String) o) != null) {
System.setProperty((String) o, properties.getProperty((String) o));
}
});
}
final MavenEmbedder mavenEmbedder = newMavenEmbedder();
try {
if (stdout != null) {
System.setOut(stdout);
}
if (stderr != null) {
System.setErr(stderr);
}
final MavenRequest mavenRequest = MavenProjectLoader.createMavenRequest(false);
mavenRequest.setGoals(Arrays.asList(goals));
mavenRequest.setPom(pom.getAbsolutePath());
final MavenExecutionResult result = mavenEmbedder.execute(mavenRequest);
if (result.hasExceptions()) {
for (Throwable t : result.getExceptions()) {
LOG.error("Error Running Maven", t);
}
throw new BuildException("Maven found issues trying to build the pom file: " + pom.getAbsolutePath() + ". Look at the Error Logs for more information");
}
} catch (final MavenEmbedderException ex) {
throw new BuildException("Maven coudn't build the project for pom file: " + pom.getAbsolutePath(), ex);
} finally {
System.setProperties(oldProperties);
mavenEmbedder.dispose();
System.setOut(oldout);
System.setErr(olderr);
}
}
use of org.appformer.maven.integration.embedder.MavenRequest in project kie-wb-common by kiegroup.
the class ArchetypeGenerateCommandTest method buildMavenRequestTest.
@Test
public void buildMavenRequestTest() {
final ArchetypeGenerateCommand command = new ArchetypeGenerateCommand(BASE_DIRECTORY, createGav(), createGav());
final MavenRequest request = command.buildMavenRequest();
assertFalse(request.isInteractive());
assertThat(request.getGoals()).isEqualTo(ArchetypeGenerateCommand.GOALS);
}
use of org.appformer.maven.integration.embedder.MavenRequest in project kie-wb-common by kiegroup.
the class ExecuteGoalsCommand method buildMavenRequest.
@Override
public MavenRequest buildMavenRequest() {
final String pomPath = baseDirectory + FileSystems.getDefault().getSeparator() + POM_XML;
final MavenRequest mavenRequest = MavenProjectLoader.createMavenRequest(false);
mavenRequest.setGoals(goals);
mavenRequest.setPom(pomPath);
return mavenRequest;
}
use of org.appformer.maven.integration.embedder.MavenRequest in project kie-wb-common by kiegroup.
the class ArchetypeGenerateCommand method buildMavenRequest.
@Override
public MavenRequest buildMavenRequest() {
final MavenRequest mavenRequest = MavenProjectLoader.createMavenRequest(false);
mavenRequest.setGoals(GOALS);
mavenRequest.setInteractive(false);
return mavenRequest;
}
use of org.appformer.maven.integration.embedder.MavenRequest in project kie-wb-common by kiegroup.
the class AbstractMavenCommand method execute.
public MavenExecutionResult execute() throws MavenEmbedderException {
final MavenEmbedder mavenEmbedder = createMavenEmbedder();
final MavenRequest mavenRequest = prepareExecution();
try {
return mavenEmbedder.execute(mavenRequest);
} finally {
mavenEmbedder.dispose();
}
}
Aggregations