Java Code Examples for org.apache.maven.plugin.MojoExecutionException#getCause()

The following examples show how to use org.apache.maven.plugin.MojoExecutionException#getCause() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LessCompilerMojo.java    From wisdom with Apache License 2.0 6 votes vote down vote up
private WatchingException buildWatchingException(String stream, File file, MojoExecutionException e) {
    String[] lines = stream.split("\n");
    for (String l : lines) {
        if (!Strings.isNullOrEmpty(l)) {
            stream = l.trim();
            break;
        }
    }
    final Matcher matcher = LESS_ERROR_PATTERN.matcher(stream);
    if (matcher.matches()) {
        String line = matcher.group(2);
        String character = matcher.group(3);
        String reason = matcher.group(1);
        return new WatchingException("Less Compilation Error", reason, file,
                Integer.valueOf(line), Integer.valueOf(character), null);
    } else {
        return new WatchingException("Less Compilation Error", stream, file, e.getCause());
    }
}
 
Example 2
Source File: UnsignTask.java    From webstart with MIT License 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
public void check( JnlpDependencyConfig config )
{
    if ( config == null )
    {
        throw new NullPointerException( "config can't be null" );
    }
    if ( config.getArtifact() == null )
    {
        throw new NullPointerException( "config.artifact can't be null" );
    }
    if ( config.getArtifact().getFile() == null )
    {
        throw new NullPointerException( "config.artifact.file can't be null" );
    }
    if ( !config.isSign() )
    {
        throw new IllegalStateException( "Can't sign if config.isSign is false" );
    }

    File file = config.getArtifact().getFile();

    boolean jarSigned;
    try
    {
        jarSigned = signTool.isJarSigned( file );
    }
    catch ( MojoExecutionException e )
    {
        throw new RuntimeException( e.getMessage(), e.getCause() );
    }

    if ( jarSigned && !config.isCanUnsign() )
    {
        throw new IllegalStateException( "Can't unsign the config.artifact.file if config.isCanUsign is false" );
    }
}
 
Example 3
Source File: SignTask.java    From webstart with MIT License 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
public void check( JnlpDependencyConfig config )
{
    if ( config == null )
    {
        throw new NullPointerException( "config can't be null" );
    }
    if ( config.getArtifact() == null )
    {
        throw new NullPointerException( "config.artifact can't be null" );
    }
    if ( config.getArtifact().getFile() == null )
    {
        throw new NullPointerException( "config.artifact.file can't be null" );
    }
    if ( !config.isSign() )
    {
        throw new IllegalStateException( "Can't sign if config.isSign is false" );
    }

    File file = config.getArtifact().getFile();

    boolean jarSigned;
    try
    {
        jarSigned = signTool.isJarSigned( file );
    }
    catch ( MojoExecutionException e )
    {
        throw new RuntimeException( e.getMessage(), e.getCause() );
    }

    if ( jarSigned && !config.isCanUnsign() )
    {
        throw new IllegalStateException( "Can't unsign the config.artifact.file if config.isCanUsign is false" );
    }
}
 
Example 4
Source File: JavaCompilerMojo.java    From wisdom with Apache License 2.0 5 votes vote down vote up
private void compile() throws WatchingException {
    try {
        execute();
    } catch (MojoExecutionException e) {
        if (e.getCause() != null
                && e.getCause().getClass().getName().equals("org.apache.maven.plugin.compiler" +
                ".CompilationFailureException")) {
            throw CompilerExecutor.build(this, e.getCause());
        }
        throw new WatchingException("Compilation error", e);
    }
}
 
Example 5
Source File: JavaTestCompilerMojo.java    From wisdom with Apache License 2.0 5 votes vote down vote up
private void compile() throws WatchingException {
    try {
        execute();
    } catch (MojoExecutionException e) {
        if (e.getCause() != null
                && e.getCause().getClass().getName().equals("org.apache.maven.plugin.compiler" +
                ".CompilationFailureException")) {
            throw CompilerExecutor.build(this, e.getCause());
        }
        throw new WatchingException("Compilation error", e);
    }
}
 
Example 6
Source File: DevMojo.java    From ci.maven with Apache License 2.0 5 votes vote down vote up
@Override
public void runUnitTests() throws PluginExecutionException, PluginScenarioException {
    try {
        runTestMojo("org.apache.maven.plugins", "maven-surefire-plugin", "test");
        runTestMojo("org.apache.maven.plugins", "maven-surefire-report-plugin", "report-only");
    } catch (MojoExecutionException e) {
        Throwable cause = e.getCause();
        if (cause != null && cause instanceof MojoFailureException) {
            throw new PluginScenarioException("Unit tests failed: " + cause.getLocalizedMessage(), e);
        } else {
            throw new PluginExecutionException("Failed to run unit tests", e);
        }
    }
}
 
Example 7
Source File: DevMojo.java    From ci.maven with Apache License 2.0 5 votes vote down vote up
@Override
public void runIntegrationTests() throws PluginExecutionException, PluginScenarioException {
    try {
        runTestMojo("org.apache.maven.plugins", "maven-failsafe-plugin", "integration-test");
        runTestMojo("org.apache.maven.plugins", "maven-surefire-report-plugin", "failsafe-report-only");
        runTestMojo("org.apache.maven.plugins", "maven-failsafe-plugin", "verify");
    } catch (MojoExecutionException e) {
        Throwable cause = e.getCause();
        if (cause != null && cause instanceof MojoFailureException) {
            throw new PluginScenarioException("Integration tests failed: " + cause.getLocalizedMessage(), e);
        } else {
            throw new PluginExecutionException("Failed to run integration tests", e);
        }
    }
}