Exemplo n.º 1
0
  // TODO: need to externalize CliRequest
  public int doMain(CliRequest cliRequest) {
    PlexusContainer localContainer = null;
    try {
      initialize(cliRequest);
      cli(cliRequest);
      logging(cliRequest);
      version(cliRequest);
      properties(cliRequest);
      localContainer = container(cliRequest);
      commands(cliRequest);
      settings(cliRequest);
      toolchains(cliRequest);
      populateRequest(cliRequest);
      encryption(cliRequest);
      repository(cliRequest);
      return execute(cliRequest);
    } catch (ExitException e) {
      return e.exitCode;
    } catch (UnrecognizedOptionException e) {
      // pure user error, suppress stack trace
      return 1;
    } catch (BuildAbort e) {
      CLIReportingUtils.showError(slf4jLogger, "ABORTED", e, cliRequest.showErrors);

      return 2;
    } catch (Exception e) {
      CLIReportingUtils.showError(slf4jLogger, "Error executing Maven.", e, cliRequest.showErrors);

      return 1;
    } finally {
      if (localContainer != null) {
        localContainer.dispose();
      }
    }
  }
Exemplo n.º 2
0
  // TODO: need to externalize CliRequest
  public int doMain(CliRequest cliRequest) {
    try {
      initialize(cliRequest);
      // Need to process cli options first to get possible logging options
      cli(cliRequest);
      logging(cliRequest);
      commands(cliRequest);
      properties(cliRequest);
      container(cliRequest);
      settings(cliRequest);
      populateRequest(cliRequest);
      encryption(cliRequest);
      return execute(cliRequest);
    } catch (ExitException e) {
      return e.exitCode;
    } catch (UnrecognizedOptionException e) {
      // pure user error, suppress stack trace
      return 1;
    } catch (Exception e) {
      CLIReportingUtils.showError(logger, "Error executing Maven.", e, cliRequest.showErrors);

      return 1;
    } finally {
      if (cliRequest.fileStream != null) {
        cliRequest.fileStream.close();
      }
    }
  }
Exemplo n.º 3
0
    public int execute(final MavenExecutionRequest request) throws Exception {
      assert request != null;

      if (log.isDebugEnabled()) {
        log.debug("Processing request: {}", Yarn.render(request, Yarn.Style.MULTI));
      }
      configureRequest(request);

      try {
        return doExecute(request);
      } catch (Exception e) {
        CLIReportingUtils.showError(
            logger, "Error executing Maven.", e, request.isShowErrors()); // TODO: i81n
        return 1;
      } finally {
        container.dispose();

        Closer.close(logStream);
      }
    }