List of usage examples for org.apache.maven.exception DefaultExceptionHandler DefaultExceptionHandler
DefaultExceptionHandler
From source file:hudson.maven.util.ExecutionEventLogger.java
License:Apache License
private void logErrors(MavenSession session) { MavenExecutionResult result = session.getResult(); // show all errors and them references as in MavenCli if (!result.getExceptions().isEmpty()) { ExceptionHandler handler = new DefaultExceptionHandler(); Map<String, String> references = new LinkedHashMap<String, String>(); for (Throwable exception : result.getExceptions()) { ExceptionSummary summary = handler.handleException(exception); logErrorSummary(summary, references, "", logger.isDebugEnabled()); }/*from w w w. ja va2s . com*/ if (!references.isEmpty()) { logger.error("For more information about the errors and possible solutions" + ", please read the following articles:"); for (Map.Entry<String, String> entry : references.entrySet()) { logger.error(entry.getValue() + " " + entry.getKey()); } } } }
From source file:org.commonjava.emb.boot.embed.EMBEmbedder.java
License:Apache License
public int formatErrorOutput(final EMBExecutionRequest request, final MavenExecutionResult result) { if (result.hasExceptions()) { final ExceptionHandler handler = new DefaultExceptionHandler(); final Map<String, String> references = new LinkedHashMap<String, String>(); MavenProject project = null;//from w ww .ja v a 2 s . c o m for (final Throwable exception : result.getExceptions()) { final ExceptionSummary summary = handler.handleException(exception); logSummary(summary, references, "", shouldShowErrors); if (project == null && exception instanceof LifecycleExecutionException) { project = ((LifecycleExecutionException) exception).getProject(); } } logger.error(""); if (!shouldShowErrors) { logger.error("To see the full stack trace of the errors, re-run Maven with the -e switch."); } if (!logger.isDebugEnabled()) { logger.error("Re-run Maven using the -X switch to enable full debug logging."); } if (!references.isEmpty()) { logger.error(""); logger.error("For more information about the errors and possible solutions" + ", please read the following articles:"); for (final Map.Entry<String, String> entry : references.entrySet()) { logger.error(entry.getValue() + " " + entry.getKey()); } } if (project != null && !project.equals(result.getTopologicallySortedProjects().get(0))) { logger.error(""); logger.error("After correcting the problems, you can resume the build with the command"); logger.error(" mvn <goals> -rf :" + project.getArtifactId()); } if (MavenExecutionRequest.REACTOR_FAIL_NEVER.equals(request.getReactorFailureBehavior())) { logger.info("Build failures were ignored."); return 0; } else { return 1; } } else { return 0; } }
From source file:org.kie.workbench.common.services.backend.compiler.external339.AFMavenCli.java
License:Apache License
protected int execute(AFCliRequest cliRequest) throws MavenExecutionRequestPopulationException { MavenExecutionRequest request = executionRequestPopulator.populateDefaults(cliRequest.getRequest()); eventSpyDispatcher.onEvent(request); MavenExecutionResult result = maven.execute(request); eventSpyDispatcher.onEvent(result);//from w w w .ja v a 2s.c om eventSpyDispatcher.close(); if (result.hasExceptions()) { ExceptionHandler handler = new DefaultExceptionHandler(); Map<String, String> references = new LinkedHashMap<String, String>(); MavenProject project = null; for (Throwable exception : result.getExceptions()) { ExceptionSummary summary = handler.handleException(exception); logSummary(summary, references, "", cliRequest.isShowErrors()); if (project == null && exception instanceof LifecycleExecutionException) { project = ((LifecycleExecutionException) exception).getProject(); } } slf4jLogger.error(""); if (!cliRequest.isShowErrors()) { slf4jLogger.error("To see the full stack trace of the errors, re-run Maven with the -e switch."); } if (!slf4jLogger.isDebugEnabled()) { slf4jLogger.error("Re-run Maven using the -X switch to enable full debug logging."); } if (!references.isEmpty()) { slf4jLogger.error(""); slf4jLogger.error("For more information about the errors and possible solutions" + ", please read the following articles:"); for (Map.Entry<String, String> entry : references.entrySet()) { slf4jLogger.error(entry.getValue() + " " + entry.getKey()); } } if (project != null && !project.equals(result.getTopologicallySortedProjects().get(0))) { slf4jLogger.error(""); slf4jLogger.error("After correcting the problems, you can resume the build with the command"); slf4jLogger.error(" mvn <goals> -rf :" + project.getArtifactId()); } if (MavenExecutionRequest.REACTOR_FAIL_NEVER .equals(cliRequest.getRequest().getReactorFailureBehavior())) { slf4jLogger.info("Build failures were ignored."); return 0; } else { return 1; } } else { return 0; } }
From source file:org.kie.workbench.common.services.backend.compiler.impl.external339.AFMavenCli.java
License:Apache License
protected int execute(AFCliRequest cliRequest) throws MavenExecutionRequestPopulationException { MavenExecutionRequest request = executionRequestPopulator.populateDefaults(cliRequest.getRequest()); eventSpyDispatcher.onEvent(request); MavenExecutionResult result = maven.execute(request); eventSpyDispatcher.onEvent(result);/* w ww. j ava2 s . c o m*/ eventSpyDispatcher.close(); if (result.hasExceptions()) { ExceptionHandler handler = new DefaultExceptionHandler(); Map<String, String> references = new LinkedHashMap<String, String>(); MavenProject project = null; for (Throwable exception : result.getExceptions()) { ExceptionSummary summary = handler.handleException(exception); logSummary(summary, references, "", cliRequest.isShowErrors()); if (project == null && exception instanceof LifecycleExecutionException) { project = ((LifecycleExecutionException) exception).getProject(); } } slf4jLogger.error(""); if (!cliRequest.isShowErrors()) { slf4jLogger.error("To see the full stack trace of the errors, re-run Maven with the -e switch."); } if (!slf4jLogger.isDebugEnabled()) { slf4jLogger.error("Re-run Maven using the -X switch to enable full debug logging."); } if (!references.isEmpty()) { slf4jLogger.error(""); slf4jLogger.error("For more information about the errors and possible solutions" + ", please read the following articles:"); for (Entry<String, String> entry : references.entrySet()) { slf4jLogger.error(entry.getValue() + " " + entry.getKey()); } } if (project != null && !project.equals(result.getTopologicallySortedProjects().get(0))) { slf4jLogger.error(""); slf4jLogger.error("After correcting the problems, you can resume the build with the command"); slf4jLogger.error(" mvn <goals> -rf :" + project.getArtifactId()); } if (MavenExecutionRequest.REACTOR_FAIL_NEVER .equals(cliRequest.getRequest().getReactorFailureBehavior())) { slf4jLogger.info("Build failures were ignored."); return 0; } else { return 1; } } else { return 0; } }
From source file:org.kie.workbench.common.services.backend.compiler.impl.external339.ReusableAFMavenCli.java
License:Apache License
protected int execute(AFCliRequest cliRequest) throws MavenExecutionRequestPopulationException { MavenExecutionRequest request = reusableExecutionRequestPopulator.populateDefaults(cliRequest.getRequest()); reusableEventSpyDispatcher.onEvent(request); MavenExecutionResult result = reusableMaven.execute(request); reusableEventSpyDispatcher.onEvent(result); reusableEventSpyDispatcher.close();/*from w w w. j a va 2s. co m*/ if (result.hasExceptions()) { ExceptionHandler handler = new DefaultExceptionHandler(); Map<String, String> references = new LinkedHashMap<String, String>(); MavenProject project = null; for (Throwable exception : result.getExceptions()) { ExceptionSummary summary = handler.handleException(exception); logSummary(summary, references, "", cliRequest.isShowErrors()); if (project == null && exception instanceof LifecycleExecutionException) { project = ((LifecycleExecutionException) exception).getProject(); } } reusableSlf4jLogger.error(""); if (!cliRequest.isShowErrors()) { reusableSlf4jLogger .error("To see the full stack trace of the errors, re-run Maven with the -e switch."); } if (!reusableSlf4jLogger.isDebugEnabled()) { reusableSlf4jLogger.error("Re-run Maven using the -X switch to enable full debug logging."); } if (!references.isEmpty()) { reusableSlf4jLogger.error(""); reusableSlf4jLogger.error("For more information about the errors and possible solutions" + ", please read the following articles:"); for (Entry<String, String> entry : references.entrySet()) { reusableSlf4jLogger.error(entry.getValue() + " " + entry.getKey()); } } if (project != null && !project.equals(result.getTopologicallySortedProjects().get(0))) { reusableSlf4jLogger.error(""); reusableSlf4jLogger .error("After correcting the problems, you can resume the build with the command"); reusableSlf4jLogger.error(" mvn <goals> -rf :" + project.getArtifactId()); } if (MavenExecutionRequest.REACTOR_FAIL_NEVER .equals(cliRequest.getRequest().getReactorFailureBehavior())) { reusableSlf4jLogger.info("Build failures were ignored."); return 0; } else { return 1; } } else { return 0; } }
From source file:org.topdesk.maven.tracker.MavenCli.java
License:Apache License
private int execute(CliRequest cliRequest) { MavenExecutionResult result = maven.execute(cliRequest.request); if (result.hasExceptions()) { ExceptionHandler handler = new DefaultExceptionHandler(); Map<String, String> references = new LinkedHashMap<String, String>(); MavenProject project = null;/*from w w w . j a v a2 s . co m*/ for (Throwable exception : result.getExceptions()) { ExceptionSummary summary = handler.handleException(exception); logSummary(summary, references, "", cliRequest.showErrors); if (project == null && exception instanceof LifecycleExecutionException) { project = ((LifecycleExecutionException) exception).getProject(); } } logger.error(""); if (!cliRequest.showErrors) { logger.error("To see the full stack trace of the errors, re-run Maven with the -e switch."); } if (!logger.isDebugEnabled()) { logger.error("Re-run Maven using the -X switch to enable full debug logging."); } if (!references.isEmpty()) { logger.error(""); logger.error("For more information about the errors and possible solutions" + ", please read the following articles:"); for (Map.Entry<String, String> entry : references.entrySet()) { logger.error(entry.getValue() + " " + entry.getKey()); } } if (project != null && !project.equals(result.getTopologicallySortedProjects().get(0))) { logger.error(""); logger.error("After correcting the problems, you can resume the build with the command"); logger.error(" mvn <goals> -rf :" + project.getArtifactId()); } if (MavenExecutionRequest.REACTOR_FAIL_NEVER.equals(cliRequest.request.getReactorFailureBehavior())) { logger.info("Build failures were ignored."); return 0; } else { return 1; } } else { return 0; } }