Search in sources :

Example 1 with SystemOutHandler

use of org.apache.maven.shared.invoker.SystemOutHandler in project scala-maven-plugin by davidB.

the class ScalaContinuousTestMojo method postCompileActions.

@Override
protected void postCompileActions() throws Exception {
    if (test == null) {
        getLog().info("Now running all the unit tests. Use -Dtest=FooTest to run a single test by name");
    } else {
        getLog().info("Now running tests matching: " + test);
    }
    final InvocationRequest request = new DefaultInvocationRequest();
    request.setLocalRepositoryDirectory(localRepositoryPath);
    request.setInteractive(false);
    request.setErrorHandler(new SystemOutHandler(true));
    request.setOutputHandler(new SystemOutHandler(true));
    request.setBaseDirectory(project.getBasedir());
    request.setPomFile(new File(project.getBasedir(), "pom.xml"));
    request.setGoals(getMavenGoals());
    request.setOffline(false);
    if (test != null) {
        Properties properties = new Properties();
        properties.put("test", test);
        request.setProperties(properties);
    }
    if (getLog().isDebugEnabled()) {
        try {
            getLog().debug("Executing: " + new MavenCommandLineBuilder().build(request));
        } catch (CommandLineConfigurationException e) {
            getLog().debug("Failed to display command line: " + e.getMessage());
        }
    }
    try {
        invoker.execute(request);
    } catch (final MavenInvocationException e) {
        getLog().debug("Error invoking Maven: " + e.getMessage(), e);
        throw new BuildFailureException("Maven invocation failed. " + e.getMessage(), e);
    }
}
Also used : DefaultInvocationRequest(org.apache.maven.shared.invoker.DefaultInvocationRequest) InvocationRequest(org.apache.maven.shared.invoker.InvocationRequest) BuildFailureException(org.apache.maven.BuildFailureException) MavenInvocationException(org.apache.maven.shared.invoker.MavenInvocationException) SystemOutHandler(org.apache.maven.shared.invoker.SystemOutHandler) DefaultInvocationRequest(org.apache.maven.shared.invoker.DefaultInvocationRequest) MavenCommandLineBuilder(org.apache.maven.shared.invoker.MavenCommandLineBuilder) CommandLineConfigurationException(org.apache.maven.shared.invoker.CommandLineConfigurationException) Properties(java.util.Properties) File(java.io.File)

Aggregations

File (java.io.File)1 Properties (java.util.Properties)1 BuildFailureException (org.apache.maven.BuildFailureException)1 CommandLineConfigurationException (org.apache.maven.shared.invoker.CommandLineConfigurationException)1 DefaultInvocationRequest (org.apache.maven.shared.invoker.DefaultInvocationRequest)1 InvocationRequest (org.apache.maven.shared.invoker.InvocationRequest)1 MavenCommandLineBuilder (org.apache.maven.shared.invoker.MavenCommandLineBuilder)1 MavenInvocationException (org.apache.maven.shared.invoker.MavenInvocationException)1 SystemOutHandler (org.apache.maven.shared.invoker.SystemOutHandler)1