Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMickael Istria2019-01-08 09:33:12 -0500
committerMickael Istria2019-01-08 09:33:59 -0500
commit4ebbcc3164c96eb8e1b965bac0eefc2d8e7eab52 (patch)
tree0a15e07a7ca3067d1a27290d49329336281d9d3b
parent048850a7372c7631896a24cfbe94fea7d7cd4676 (diff)
downloadm2e-core-4ebbcc3164c96eb8e1b965bac0eefc2d8e7eab52.tar.gz
m2e-core-4ebbcc3164c96eb8e1b965bac0eefc2d8e7eab52.tar.xz
m2e-core-4ebbcc3164c96eb8e1b965bac0eefc2d8e7eab52.zip
Better report MavenProblems
Drill down some exceptions to get more details about problem and improve error messages and locations. Change-Id: I21bec965b700fbaed9f16e1ab47c5bc0431c8efb Signed-off-by: Mickael Istria <mistria@redhat.com>
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/markers/MavenMarkerManager.java27
1 files changed, 23 insertions, 4 deletions
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/markers/MavenMarkerManager.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/markers/MavenMarkerManager.java
index 01f2c6b3..b297bc86 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/markers/MavenMarkerManager.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/markers/MavenMarkerManager.java
@@ -12,6 +12,8 @@
package org.eclipse.m2e.core.internal.markers;
import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -37,6 +39,7 @@ import org.apache.maven.model.building.ModelProblem.Severity;
import org.apache.maven.project.DependencyResolutionResult;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.ProjectBuildingException;
+import org.apache.maven.project.ProjectBuildingResult;
import org.eclipse.m2e.core.embedder.IMavenConfiguration;
import org.eclipse.m2e.core.internal.Messages;
@@ -197,10 +200,9 @@ public class MavenMarkerManager implements IMavenMarkerManager {
String errorMessage = getArtifactId(abstractArtifactResolutionException) + " " + getRootErrorMessage(ex); //$NON-NLS-1$
result.add(new MavenProblemInfo(errorMessage, location));
} else if(ex instanceof ProjectBuildingException) {
- Throwable cause = ex.getCause();
- if(cause instanceof ModelBuildingException) {
- ModelBuildingException mbe = (ModelBuildingException) cause;
- for(ModelProblem problem : mbe.getProblems()) {
+ Collection<ModelProblem> modelProblems = getModelProblems((ProjectBuildingException)ex);
+ if (modelProblems != null && !modelProblems.isEmpty()) {
+ for(ModelProblem problem : modelProblems) {
String message = NLS.bind(Messages.pluginMarkerBuildError, problem.getMessage());
int severity = (Severity.WARNING == problem.getSeverity()) ? IMarker.SEVERITY_WARNING
: IMarker.SEVERITY_ERROR;
@@ -218,6 +220,23 @@ public class MavenMarkerManager implements IMavenMarkerManager {
return result;
}
+ private Collection<ModelProblem> getModelProblems(ProjectBuildingException ex) {
+ if (ex.getCause() instanceof ModelBuildingException) {
+ return ((ModelBuildingException)ex.getCause()).getProblems();
+ }
+ Set<ModelProblem> problems = new HashSet<>();
+ for(ProjectBuildingResult projectBuildingResult : ex.getResults()) {
+ Collection<ModelProblem> current = projectBuildingResult.getProblems();
+ if(current != null) {
+ problems.addAll(projectBuildingResult.getProblems());
+ }
+ }
+ if(!problems.isEmpty()) {
+ return problems;
+ }
+ return null;
+ }
+
@Override
public void deleteMarkers(IResource resource, String type) throws CoreException {
deleteMarkers(resource, true /*includeSubtypes*/, type);

Back to the top