Search in sources :

Example 1 with BuildAbort

use of org.apache.maven.BuildAbort in project kie-wb-common by kiegroup.

the class AFMavenCli method doMain.

public int doMain(AFCliRequest cliRequest, ClassWorld classWorld) {
    PlexusContainer localContainer = null;
    try {
        initialize(cliRequest);
        cli(cliRequest);
        logging(cliRequest);
        version(cliRequest);
        properties(cliRequest);
        localContainer = container(cliRequest, classWorld);
        commands(cliRequest);
        configure(cliRequest);
        toolchains(cliRequest);
        populateRequest(cliRequest);
        repository(cliRequest);
        return execute(cliRequest);
    } catch (ExitException e) {
        e.getStackTrace();
        return e.exitCode;
    } catch (UnrecognizedOptionException e) {
        e.getStackTrace();
        return 1;
    } catch (BuildAbort e) {
        e.getStackTrace();
        AFCLIReportingUtils.showError(slf4jLogger, "ABORTED", e, cliRequest.isShowErrors());
        return 2;
    } catch (Exception e) {
        e.getStackTrace();
        AFCLIReportingUtils.showError(slf4jLogger, "Error executing Maven.", e, cliRequest.isShowErrors());
        return 1;
    } finally {
        if (localContainer != null) {
            localContainer.dispose();
            localContainer = null;
        }
    }
}
Also used : DefaultPlexusContainer(org.codehaus.plexus.DefaultPlexusContainer) PlexusContainer(org.codehaus.plexus.PlexusContainer) BuildAbort(org.apache.maven.BuildAbort) UnrecognizedOptionException(org.apache.commons.cli.UnrecognizedOptionException) LifecycleExecutionException(org.apache.maven.lifecycle.LifecycleExecutionException) InternalErrorException(org.apache.maven.InternalErrorException) UnrecognizedOptionException(org.apache.commons.cli.UnrecognizedOptionException) XmlPullParserException(org.codehaus.plexus.util.xml.pull.XmlPullParserException) FileNotFoundException(java.io.FileNotFoundException) ParseException(org.apache.commons.cli.ParseException) ComponentLookupException(org.codehaus.plexus.component.repository.exception.ComponentLookupException) IOException(java.io.IOException) MavenExecutionRequestPopulationException(org.apache.maven.execution.MavenExecutionRequestPopulationException)

Example 2 with BuildAbort

use of org.apache.maven.BuildAbort in project kie-wb-common by kiegroup.

the class AFMavenCli method doMain.

public int doMain(AFCliRequest cliRequest, ClassWorld classWorld) {
    PlexusContainer localContainer = null;
    PrintStream originalOut = System.out;
    PrintStream originalErr = System.err;
    try {
        initialize(cliRequest);
        cli(cliRequest);
        logging(cliRequest);
        version(cliRequest);
        properties(cliRequest);
        localContainer = container(cliRequest, classWorld);
        commands(cliRequest);
        configure(cliRequest);
        toolchains(cliRequest);
        populateRequest(cliRequest);
        repository(cliRequest);
        return execute(cliRequest);
    } catch (ExitException e) {
        e.getStackTrace();
        return e.exitCode;
    } catch (UnrecognizedOptionException e) {
        e.getStackTrace();
        return 1;
    } catch (BuildAbort e) {
        e.getStackTrace();
        AFCLIReportingUtils.showError(slf4jLogger, "ABORTED", e, cliRequest.isShowErrors());
        return 2;
    } catch (Exception e) {
        e.getStackTrace();
        AFCLIReportingUtils.showError(slf4jLogger, "Error executing Maven.", e, cliRequest.isShowErrors());
        return 1;
    } finally {
        System.setOut(originalOut);
        System.setErr(originalErr);
        if (localContainer != null) {
            localContainer.dispose();
            localContainer = null;
        }
    }
}
Also used : PrintStream(java.io.PrintStream) DefaultPlexusContainer(org.codehaus.plexus.DefaultPlexusContainer) PlexusContainer(org.codehaus.plexus.PlexusContainer) BuildAbort(org.apache.maven.BuildAbort) UnrecognizedOptionException(org.apache.commons.cli.UnrecognizedOptionException) LifecycleExecutionException(org.apache.maven.lifecycle.LifecycleExecutionException) InternalErrorException(org.apache.maven.InternalErrorException) UnrecognizedOptionException(org.apache.commons.cli.UnrecognizedOptionException) XmlPullParserException(org.codehaus.plexus.util.xml.pull.XmlPullParserException) FileNotFoundException(java.io.FileNotFoundException) ParseException(org.apache.commons.cli.ParseException) ComponentLookupException(org.codehaus.plexus.component.repository.exception.ComponentLookupException) IOException(java.io.IOException) MavenExecutionRequestPopulationException(org.apache.maven.execution.MavenExecutionRequestPopulationException)

Example 3 with BuildAbort

use of org.apache.maven.BuildAbort in project kie-wb-common by kiegroup.

the class ReusableAFMavenCli method doMain.

public int doMain(AFCliRequest cliRequest, ClassWorld classWorld) {
    PrintStream originalOut = System.out;
    PrintStream originalErr = System.err;
    try {
        initialize(cliRequest);
        cli(cliRequest);
        logging(cliRequest);
        version(cliRequest);
        properties(cliRequest);
        reusableContainer = container(cliRequest, classWorld);
        // ok
        commands(cliRequest);
        configure(cliRequest);
        toolchains(cliRequest);
        populateRequest(cliRequest);
        repository(cliRequest);
        return execute(cliRequest);
    } catch (ExitException e) {
        // e.printStackTrace();
        e.getStackTrace();
        return e.exitCode;
    } catch (UnrecognizedOptionException e) {
        // e.printStackTrace();
        e.getStackTrace();
        return 1;
    } catch (BuildAbort e) {
        // e.printStackTrace();
        e.getStackTrace();
        AFCLIReportingUtils.showError(reusableSlf4jLogger, "ABORTED", e, cliRequest.isShowErrors());
        return 2;
    } catch (Exception e) {
        // e.printStackTrace();
        e.getStackTrace();
        AFCLIReportingUtils.showError(reusableSlf4jLogger, "Error executing Maven.", e, cliRequest.isShowErrors());
        return 1;
    } finally {
        System.setOut(originalOut);
        System.setErr(originalErr);
    }
}
Also used : PrintStream(java.io.PrintStream) BuildAbort(org.apache.maven.BuildAbort) UnrecognizedOptionException(org.apache.commons.cli.UnrecognizedOptionException) LifecycleExecutionException(org.apache.maven.lifecycle.LifecycleExecutionException) InternalErrorException(org.apache.maven.InternalErrorException) UnrecognizedOptionException(org.apache.commons.cli.UnrecognizedOptionException) XmlPullParserException(org.codehaus.plexus.util.xml.pull.XmlPullParserException) FileNotFoundException(java.io.FileNotFoundException) ParseException(org.apache.commons.cli.ParseException) ComponentLookupException(org.codehaus.plexus.component.repository.exception.ComponentLookupException) IOException(java.io.IOException) MavenExecutionRequestPopulationException(org.apache.maven.execution.MavenExecutionRequestPopulationException)

Aggregations

FileNotFoundException (java.io.FileNotFoundException)3 IOException (java.io.IOException)3 ParseException (org.apache.commons.cli.ParseException)3 UnrecognizedOptionException (org.apache.commons.cli.UnrecognizedOptionException)3 BuildAbort (org.apache.maven.BuildAbort)3 InternalErrorException (org.apache.maven.InternalErrorException)3 MavenExecutionRequestPopulationException (org.apache.maven.execution.MavenExecutionRequestPopulationException)3 LifecycleExecutionException (org.apache.maven.lifecycle.LifecycleExecutionException)3 ComponentLookupException (org.codehaus.plexus.component.repository.exception.ComponentLookupException)3 XmlPullParserException (org.codehaus.plexus.util.xml.pull.XmlPullParserException)3 PrintStream (java.io.PrintStream)2 DefaultPlexusContainer (org.codehaus.plexus.DefaultPlexusContainer)2 PlexusContainer (org.codehaus.plexus.PlexusContainer)2