Example usage for org.apache.maven BuildFailureException BuildFailureException

List of usage examples for org.apache.maven BuildFailureException BuildFailureException

Introduction

In this page you can find the example usage for org.apache.maven BuildFailureException BuildFailureException.

Prototype

public BuildFailureException(String message, Throwable cause) 

Source Link

Usage

From source file:org_scala_tools_maven.ScalaContinuousTestMojo.java

License:Apache License

@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 {//from w  w w  .  j  a v a2 s .  c o  m
        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);
    }
}