Example usage for org.apache.maven.execution MavenExecutionRequest getGoals

List of usage examples for org.apache.maven.execution MavenExecutionRequest getGoals

Introduction

In this page you can find the example usage for org.apache.maven.execution MavenExecutionRequest getGoals.

Prototype

List<String> getGoals();

Source Link

Usage

From source file:io.sundr.maven.AbstractSundrioMojo.java

License:Apache License

void backGroundBuild(MavenProject project) throws MojoExecutionException {
    MavenExecutionRequest executionRequest = session.getRequest();

    InvocationRequest request = new DefaultInvocationRequest();
    request.setBaseDirectory(project.getBasedir());
    request.setPomFile(project.getFile());
    request.setGoals(executionRequest.getGoals());
    request.setRecursive(false);//from w  w  w.j  av  a  2  s .  co  m
    request.setInteractive(false);

    request.setProfiles(executionRequest.getActiveProfiles());
    request.setProperties(executionRequest.getUserProperties());
    Invoker invoker = new DefaultInvoker();
    try {
        InvocationResult result = invoker.execute(request);
        if (result.getExitCode() != 0) {
            throw new IllegalStateException(
                    "Error invoking Maven goals:[" + StringUtils.join(executionRequest.getGoals(), ", ") + "]",
                    result.getExecutionException());
        }
    } catch (MavenInvocationException e) {
        throw new IllegalStateException(
                "Error invoking Maven goals:[" + StringUtils.join(executionRequest.getGoals(), ", ") + "]", e);
    }
}

From source file:org.openengsb.openengsbplugin.tools.DefaultMavenExecutor.java

License:Apache License

private void clearProperties(MavenExecutionRequest request) {
    request.getGoals().clear();
    request.getUserProperties().clear();
    request.getActiveProfiles().clear();
    request.getInactiveProfiles().clear();
}