Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvladt2011-01-13 20:25:12 +0000
committervladt2011-01-13 20:25:45 +0000
commitf0a415be7b68ec1b475127ca3288de7889755431 (patch)
tree9367952e27070d23f5e120f4ec11bb784234c881
parent6dbff4c371e0c8516f3b19b5adcf38a58a54d757 (diff)
downloadm2e-core-f0a415be7b68ec1b475127ca3288de7889755431.tar.gz
m2e-core-f0a415be7b68ec1b475127ca3288de7889755431.tar.xz
m2e-core-f0a415be7b68ec1b475127ca3288de7889755431.zip
MNGECLIPSE-1469: error markers are not created for maven build errors
-rw-r--r--org.eclipse.m2e.core/plugin.xml6
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/builder/AbstractEclipseBuildContext.java86
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/core/IMavenConstants.java2
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/builder/MavenBuilder.java290
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/MavenMarkerManager.java21
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/IMavenMarkerManager.java15
-rw-r--r--org.eclipse.m2e.maven.runtime/.classpath2
-rw-r--r--org.eclipse.m2e.maven.runtime/META-INF/MANIFEST.MF2
-rw-r--r--org.eclipse.m2e.maven.runtime/jars/plexus-build-api-0.0.6.jarbin8074 -> 0 bytes
-rw-r--r--org.eclipse.m2e.maven.runtime/jars/plexus-build-api-0.0.7-SNAPSHOT.jarbin0 -> 8149 bytes
-rw-r--r--org.eclipse.m2e.tests.common/src/org/eclipse/m2e/tests/common/WorkspaceHelpers.java39
11 files changed, 353 insertions, 110 deletions
diff --git a/org.eclipse.m2e.core/plugin.xml b/org.eclipse.m2e.core/plugin.xml
index b66208f1..bc540795 100644
--- a/org.eclipse.m2e.core/plugin.xml
+++ b/org.eclipse.m2e.core/plugin.xml
@@ -315,6 +315,12 @@
<super type="org.eclipse.m2e.core.maven2Problem"/>
<persistent value="true"/>
</extension>
+ <extension point="org.eclipse.core.resources.markers"
+ id="maven2Problem.build.participant"
+ name="%m2.marker.problem.build.name">
+ <super type="org.eclipse.m2e.core.maven2Problem.build"/>
+ <persistent value="true"/>
+ </extension>
<extension point="org.eclipse.ui.keywords">
<keyword id="org.eclipse.m2e.core.maven" label="%keyword.label"/>
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/builder/AbstractEclipseBuildContext.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/builder/AbstractEclipseBuildContext.java
index df3a519d..2b0bf1de 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/builder/AbstractEclipseBuildContext.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/builder/AbstractEclipseBuildContext.java
@@ -16,6 +16,7 @@ import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.HashSet;
+import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -29,8 +30,6 @@ import org.sonatype.plexus.build.incremental.BuildContext;
/**
- * AbstractEclipseBuildContext
- *
* @author igor
*/
public abstract class AbstractEclipseBuildContext implements BuildContext {
@@ -50,6 +49,9 @@ public abstract class AbstractEclipseBuildContext implements BuildContext {
this.file = file;
this.line = line;
this.column = column;
+ if(message == null && cause != null) {
+ message = cause.getMessage();
+ }
this.message = message;
this.cause = cause;
}
@@ -59,9 +61,19 @@ public abstract class AbstractEclipseBuildContext implements BuildContext {
protected final Map<String, Object> context;
- private final ArrayList<Message> errorMessages = new ArrayList<Message>();
+ private String currentBuildParticipantId;
- private final ArrayList<Message> warningMessages = new ArrayList<Message>();
+ /** Error messages by build participant id */
+ private final Map<String, List<Message>> errorMessages = new LinkedHashMap<String, List<Message>>();
+
+ /** Warning messages by build participant id */
+ private final Map<String, List<Message>> warningMessages = new LinkedHashMap<String, List<Message>>();
+
+ /** List of files to cleanup error messages for build participant id */
+ private final Map<String, List<File>> removeErrors = new LinkedHashMap<String, List<File>>();
+
+ /** List of files to cleanup warning messages for build participant id */
+ private final Map<String, List<File>> removeWarnings = new LinkedHashMap<String, List<File>>();
protected AbstractEclipseBuildContext(Map<String, Object> context) {
this.context = context;
@@ -116,21 +128,75 @@ public abstract class AbstractEclipseBuildContext implements BuildContext {
}
public void addError(File file, int line, int column, String message, Throwable cause) {
- errorMessages.add(new Message(file, line, column, message, cause));
+ if(currentBuildParticipantId == null) {
+ throw new IllegalStateException("currentBuildParticipantId cannot be null or empty");
+ }
+ List<Message> messages = errorMessages.get(currentBuildParticipantId);
+ if(messages == null) {
+ messages = new ArrayList<Message>();
+ errorMessages.put(currentBuildParticipantId, messages);
+ }
+ messages.add(new Message(file, line, column, message, cause));
}
public void addWarning(File file, int line, int column, String message, Throwable cause) {
- warningMessages.add(new Message(file, line, column, message, cause));
+ if(currentBuildParticipantId == null) {
+ throw new IllegalStateException("currentBuildParticipantId cannot be null or empty");
+ }
+ List<Message> messages = warningMessages.get(currentBuildParticipantId);
+ if(messages == null) {
+ messages = new ArrayList<Message>();
+ warningMessages.put(currentBuildParticipantId, messages);
+ }
+ messages.add(new Message(file, line, column, message, cause));
+ }
+
+ /* (non-Javadoc)
+ * @see org.sonatype.plexus.build.incremental.BuildContext#removeErrors(java.io.File)
+ */
+ public void removeErrors(File file) {
+ if(currentBuildParticipantId == null) {
+ throw new IllegalStateException("currentBuildParticipantId cannot be null or empty");
+ }
+ List<File> files = removeErrors.get(currentBuildParticipantId);
+ if(files == null) {
+ files = new ArrayList<File>();
+ removeErrors.put(currentBuildParticipantId, files);
+ }
+ files.add(file);
}
- public List<Message> getErrorMessages() {
+ /* (non-Javadoc)
+ * @see org.sonatype.plexus.build.incremental.BuildContext#removeWarnings(java.io.File)
+ */
+ public void removeWarnings(File file) {
+ if(currentBuildParticipantId == null) {
+ throw new IllegalStateException("currentBuildParticipantId cannot be null or empty");
+ }
+ List<File> files = removeWarnings.get(currentBuildParticipantId);
+ if(files == null) {
+ files = new ArrayList<File>();
+ removeWarnings.put(currentBuildParticipantId, files);
+ }
+ files.add(file);
+ }
+
+ public Map<String, List<Message>> getErrors() {
return errorMessages;
}
- public List<Message> getWarningMessages() {
+ public Map<String, List<Message>> getWarnings() {
return warningMessages;
}
+ public Map<String, List<File>> getRemoveErrors() {
+ return removeErrors;
+ }
+
+ public Map<String, List<File>> getRemoveWarnings() {
+ return removeWarnings;
+ }
+
public boolean isUptodate(File target, File source) {
IResource targetResource = getResource(target);
IResource sourceResource = getResource(source);
@@ -138,4 +204,8 @@ public abstract class AbstractEclipseBuildContext implements BuildContext {
&& sourceResource != null && sourceResource.isAccessible() && !hasDelta(source)
&& targetResource.getLocalTimeStamp() >= sourceResource.getLocalTimeStamp();
}
+
+ public void setCurrentBuildParticipantId(String currentBuildParticipantId) {
+ this.currentBuildParticipantId = currentBuildParticipantId;
+ }
}
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/core/IMavenConstants.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/core/IMavenConstants.java
index 2ab4a0ab..357d3c9c 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/core/IMavenConstants.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/core/IMavenConstants.java
@@ -34,6 +34,8 @@ public interface IMavenConstants {
public static final String MARKER_DEPENDENCY_ID = MARKER_ID + ".dependency"; //$NON-NLS-1$
public static final String MARKER_BUILD_ID = MARKER_ID + ".build"; //$NON-NLS-1$
+
+ public static final String MARKER_BUILD_PARTICIPANT_ID = MARKER_BUILD_ID + ".participant"; //$NON-NLS-1$
/**
* string that gets included in pom.xml file comments and makes the marker manager to ignore
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/builder/MavenBuilder.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/builder/MavenBuilder.java
index c6e77305..537d841a 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/builder/MavenBuilder.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/builder/MavenBuilder.java
@@ -12,10 +12,12 @@
package org.eclipse.m2e.core.internal.builder;
import java.io.File;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import java.util.Map.Entry;
import java.util.Set;
import org.slf4j.Logger;
@@ -44,6 +46,7 @@ import org.sonatype.plexus.build.incremental.ThreadBuildContext;
import org.eclipse.m2e.core.MavenPlugin;
import org.eclipse.m2e.core.builder.AbstractEclipseBuildContext;
+import org.eclipse.m2e.core.builder.AbstractEclipseBuildContext.Message;
import org.eclipse.m2e.core.builder.EclipseBuildContext;
import org.eclipse.m2e.core.builder.EclipseIncrementalBuildContext;
import org.eclipse.m2e.core.core.IMavenConstants;
@@ -69,6 +72,8 @@ public class MavenBuilder extends IncrementalProjectBuilder {
public static QualifiedName BUILD_CONTEXT_KEY = new QualifiedName(IMavenConstants.PLUGIN_ID, "BuildContext"); //$NON-NLS-1$
+ private static final String BUILD_PARTICIPANT_ID_ATTR_NAME = "buildParticipantId";
+
static interface GetDeltaCallback {
public IResourceDelta getDelta(IProject project);
}
@@ -93,121 +98,222 @@ public class MavenBuilder extends IncrementalProjectBuilder {
IMavenMarkerManager markerManager = plugin.getMavenMarkerManager();
IProject project = getProject();
- markerManager.deleteMarkers(project, IMavenConstants.MARKER_BUILD_ID);
+ markerManager.deleteMarkers(project, kind == FULL_BUILD, IMavenConstants.MARKER_BUILD_ID);
- if(project.hasNature(IMavenConstants.NATURE_ID)) {
- IFile pomResource = project.getFile(IMavenConstants.POM_FILE_NAME);
- if(pomResource == null) {
- console.logError("Project " + project.getName() + " does not have pom.xml");
- return null;
- }
+ if(!project.hasNature(IMavenConstants.NATURE_ID)) {
+ return null;
+ }
- IMavenProjectFacade projectFacade = projectManager.create(getProject(), monitor);
- if(projectFacade == null) {
- // XXX is this really possible? should we warn the user?
- return null;
- }
+ IFile pomResource = project.getFile(IMavenConstants.POM_FILE_NAME);
+ if(pomResource == null) {
+ console.logError("Project " + project.getName() + " does not have pom.xml");
+ return null;
+ }
- if (projectFacade.isStale()) {
- MavenUpdateRequest updateRequest = new MavenUpdateRequest(project, mavenConfiguration.isOffline() /*offline*/, false /*updateSnapshots*/);
- projectManager.refresh(updateRequest, monitor);
- IMavenProjectFacade facade = projectManager.create(project, monitor);
- if(facade == null){
- // error marker should have been created
- return null;
- }
- }
+ IMavenProjectFacade projectFacade = projectManager.create(getProject(), monitor);
+ if(projectFacade == null) {
+ // XXX is this really possible? should we warn the user?
+ return null;
+ }
- IResourceDelta delta = getDelta(project);
- AbstractEclipseBuildContext buildContext;
- Map<String, Object> contextState = (Map<String, Object>) project.getSessionProperty(BUILD_CONTEXT_KEY);
- if(contextState != null && (INCREMENTAL_BUILD == kind || AUTO_BUILD == kind)) {
- buildContext = new EclipseIncrementalBuildContext(delta, contextState);
- } else {
- // must be full build
- contextState = new HashMap<String, Object>();
- project.setSessionProperty(BUILD_CONTEXT_KEY, contextState);
- buildContext = new EclipseBuildContext(project, contextState);
+ if(projectFacade.isStale()) {
+ MavenUpdateRequest updateRequest = new MavenUpdateRequest(project, mavenConfiguration.isOffline() /*offline*/,
+ false /*updateSnapshots*/);
+ projectManager.refresh(updateRequest, monitor);
+ IMavenProjectFacade facade = projectManager.create(project, monitor);
+ if(facade == null) {
+ // error marker should have been created
+ return null;
}
+ }
- Set<IProject> dependencies = new HashSet<IProject>();
+ MavenProject mavenProject = null;
+ try {
+ mavenProject = projectFacade.getMavenProject(monitor);
+ } catch(CoreException ce) {
+ //unable to read the project facade
+ addErrorMarker(ce);
+ monitor.done();
+ return null;
+ }
- IMaven maven = MavenPlugin.getDefault().getMaven();
- MavenExecutionRequest request = projectManager.createExecutionRequest(pomResource, projectFacade.getResolverConfiguration(), monitor);
-
- MavenProject mavenProject = null;
- try{
- mavenProject = projectFacade.getMavenProject(monitor);
- } catch(CoreException ce){
- //unable to read the project facade
- addErrorMarker(ce);
- monitor.done();
- return null;
- }
- MavenSession session = maven.createSession(request, mavenProject);
- ILifecycleMapping lifecycleMapping = configurationManager.getLifecycleMapping(projectFacade, monitor);
+ ILifecycleMapping lifecycleMapping = configurationManager.getLifecycleMapping(projectFacade, monitor);
+ if(lifecycleMapping == null || !projectFacade.hasValidConfiguration()) {
+ return null;
+ }
- if(lifecycleMapping != null && projectFacade.hasValidConfiguration()) {
- ThreadBuildContext.setThreadBuildContext(buildContext);
+ Set<IProject> dependencies = new HashSet<IProject>();
+
+ IMaven maven = MavenPlugin.getDefault().getMaven();
+ MavenExecutionRequest request = projectManager.createExecutionRequest(pomResource,
+ projectFacade.getResolverConfiguration(), monitor);
+ MavenSession session = maven.createSession(request, mavenProject);
+
+ IResourceDelta delta = getDelta(project);
+ Map<String, Object> contextState = (Map<String, Object>) project.getSessionProperty(BUILD_CONTEXT_KEY);
+ AbstractEclipseBuildContext buildContext;
+ if(contextState != null && (INCREMENTAL_BUILD == kind || AUTO_BUILD == kind)) {
+ buildContext = new EclipseIncrementalBuildContext(delta, contextState);
+ } else {
+ // must be full build
+ contextState = new HashMap<String, Object>();
+ project.setSessionProperty(BUILD_CONTEXT_KEY, contextState);
+ buildContext = new EclipseBuildContext(project, contextState);
+ }
+
+ List<Throwable> buildErrors = new ArrayList<Throwable>();
+ ThreadBuildContext.setThreadBuildContext(buildContext);
+ try {
+ List<AbstractBuildParticipant> participants = lifecycleMapping.getBuildParticipants(monitor);
+ for(InternalBuildParticipant participant : participants) {
+ //TODO Use actual mojo execution key
+ String stringMojoExecutionKey = "xyz";
+ buildContext.setCurrentBuildParticipantId(stringMojoExecutionKey + "-" + participant.getClass().getName());
+ participant.setMavenProjectFacade(projectFacade);
+ participant.setGetDeltaCallback(getDeltaCallback);
+ participant.setSession(session);
+ participant.setBuildContext(buildContext);
try {
- List<AbstractBuildParticipant> participants = lifecycleMapping.getBuildParticipants(monitor);
- for(InternalBuildParticipant participant : participants) {
- participant.setMavenProjectFacade(projectFacade);
- participant.setGetDeltaCallback(getDeltaCallback);
- participant.setSession(session);
- participant.setBuildContext(buildContext);
- try {
- if(FULL_BUILD == kind || delta != null || participant.callOnEmptyDelta()) {
- Set<IProject> sub = participant.build(kind, monitor);
- if(sub != null) {
- dependencies.addAll(sub);
- }
- }
- } catch(Exception e) {
- log.debug("Exception in build participant", e);
- addErrorMarker(e);
- } finally {
- participant.setMavenProjectFacade(null);
- participant.setGetDeltaCallback(null);
- participant.setSession(null);
- participant.setBuildContext(null);
+ if(FULL_BUILD == kind || delta != null || participant.callOnEmptyDelta()) {
+ Set<IProject> sub = participant.build(kind, monitor);
+ if(sub != null) {
+ dependencies.addAll(sub);
}
}
- } catch(CoreException e) {
- addErrorMarker(e);
+ } catch(Exception e) {
+ log.debug("Exception in build participant", e);
+ buildErrors.add(e);
} finally {
- ThreadBuildContext.setThreadBuildContext(null);
+ participant.setMavenProjectFacade(null);
+ participant.setGetDeltaCallback(null);
+ participant.setSession(null);
+ participant.setBuildContext(null);
}
}
+ } catch(CoreException e) {
+ addErrorMarker(e);
+ } finally {
+ ThreadBuildContext.setThreadBuildContext(null);
+ }
- for(File file : buildContext.getFiles()) {
- IPath path = getProjectRelativePath(project, file);
- if(path == null) {
- continue; // odd
+ for(File file : buildContext.getFiles()) {
+ IPath path = getProjectRelativePath(project, file);
+ if(path == null) {
+ continue; // odd
+ }
+
+ if(!file.exists()) {
+ IResource resource = project.findMember(path);
+ if(resource != null) {
+ resource.refreshLocal(IResource.DEPTH_INFINITE, monitor);
}
+ } else if(file.isDirectory()) {
+ IFolder ifolder = project.getFolder(path);
+ ifolder.refreshLocal(IResource.DEPTH_INFINITE, monitor);
+ } else {
+ IFile ifile = project.getFile(path);
+ ifile.refreshLocal(IResource.DEPTH_ZERO, monitor);
+ }
+ }
- if(!file.exists()) {
- IResource resource = project.findMember(path);
- if (resource != null) {
- resource.refreshLocal(IResource.DEPTH_INFINITE, monitor);
- }
- } else if(file.isDirectory()) {
- IFolder ifolder = project.getFolder(path);
- ifolder.refreshLocal(IResource.DEPTH_INFINITE, monitor);
- } else {
- IFile ifile = project.getFile(path);
- ifile.refreshLocal(IResource.DEPTH_ZERO, monitor);
+ MavenExecutionResult result = session.getResult();
+ for(Throwable buildError : buildErrors) {
+ result.addException(buildError);
+ }
+ processBuildResults(result, buildContext);
+ if(result.hasExceptions()) {
+ markerManager.addMarkers(pomResource, IMavenConstants.MARKER_BUILD_ID, result);
+ }
+
+ if(dependencies.isEmpty()) {
+ return null;
+ }
+ return dependencies.toArray(new IProject[dependencies.size()]);
+ }
+
+ private void processBuildResults(MavenExecutionResult result, AbstractEclipseBuildContext buildContext) {
+ MavenPlugin plugin = MavenPlugin.getDefault();
+ IMavenMarkerManager markerManager = plugin.getMavenMarkerManager();
+
+ for(Entry<String, List<File>> entry : buildContext.getRemoveErrors().entrySet()) {
+ String buildParticipantId = entry.getKey();
+ for(File file : entry.getValue()) {
+ deleteBuildParticipantMarkers(markerManager, file, IMarker.SEVERITY_ERROR, buildParticipantId);
+ }
+ }
+ for(Entry<String, List<File>> entry : buildContext.getRemoveWarnings().entrySet()) {
+ String buildParticipantId = entry.getKey();
+ for(File file : entry.getValue()) {
+ deleteBuildParticipantMarkers(markerManager, file, IMarker.SEVERITY_WARNING, buildParticipantId);
+ }
+ }
+
+ for(Entry<String, List<Message>> messageEntry : buildContext.getErrors().entrySet()) {
+ String buildParticipantId = messageEntry.getKey();
+ for(Message buildMessage : messageEntry.getValue()) {
+ addBuildParticipantMarker(markerManager, buildMessage, IMarker.SEVERITY_ERROR, buildParticipantId);
+
+ if(buildMessage.cause != null && result.hasExceptions()) {
+ result.getExceptions().remove(buildMessage.cause);
}
}
+ }
+ for(Entry<String, List<Message>> messageEntry : buildContext.getWarnings().entrySet()) {
+ String buildParticipantId = messageEntry.getKey();
+ for(Message buildMessage : messageEntry.getValue()) {
+ addBuildParticipantMarker(markerManager, buildMessage, IMarker.SEVERITY_WARNING, buildParticipantId);
- MavenExecutionResult result = session.getResult();
- if (result.hasExceptions()) {
- markerManager.addMarkers(pomResource, IMavenConstants.MARKER_BUILD_ID, result);
+ if(buildMessage.cause != null && result.hasExceptions()) {
+ result.getExceptions().remove(buildMessage.cause);
+ }
}
+ }
+
+ if(result.hasExceptions()) {
+ IProject project = getProject();
+ markerManager.addMarkers(project.getFile(IMavenConstants.POM_FILE_NAME), IMavenConstants.MARKER_BUILD_ID, result);
+ }
+ }
- return !dependencies.isEmpty() ? dependencies.toArray(new IProject[dependencies.size()]) : null;
+ private void deleteBuildParticipantMarkers(IMavenMarkerManager markerManager, File file, int severity,
+ String buildParticipantId) {
+ IProject project = getProject();
+
+ IPath path = getProjectRelativePath(getProject(), file);
+ IResource resource = null;
+ if(path != null) {
+ resource = project.findMember(path);
+ }
+ if(resource == null) {
+ resource = project.getFile(IMavenConstants.POM_FILE_NAME);
+ }
+ try {
+ markerManager.deleteMarkers(resource, IMavenConstants.MARKER_BUILD_PARTICIPANT_ID, severity,
+ BUILD_PARTICIPANT_ID_ATTR_NAME, buildParticipantId);
+ } catch(CoreException ex) {
+ log.error(ex.getMessage(), ex);
+ }
+ }
+
+ private void addBuildParticipantMarker(IMavenMarkerManager markerManager, Message buildMessage, int severity,
+ String buildParticipantId) {
+ IProject project = getProject();
+
+ IPath path = getProjectRelativePath(getProject(), buildMessage.file);
+ IResource resource = null;
+ if(path != null) {
+ resource = project.findMember(path);
+ }
+ if(resource == null) {
+ resource = project.getFile(IMavenConstants.POM_FILE_NAME);
+ }
+ IMarker marker = markerManager.addMarker(resource, IMavenConstants.MARKER_BUILD_PARTICIPANT_ID,
+ buildMessage.message, buildMessage.line, severity);
+ try {
+ marker.setAttribute(BUILD_PARTICIPANT_ID_ATTR_NAME, buildParticipantId);
+ } catch(CoreException ex) {
+ log.error(ex.getMessage(), ex);
}
- return null;
}
private void addErrorMarker(Exception e) {
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/MavenMarkerManager.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/MavenMarkerManager.java
index 9f1a280a..0380514c 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/MavenMarkerManager.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/MavenMarkerManager.java
@@ -504,7 +504,6 @@ public class MavenMarkerManager implements IMavenMarkerManager {
/* (non-Javadoc)
* @see org.eclipse.m2e.core.project.IMavenMarkerManager#addMarker(org.eclipse.core.resources.IResource, java.lang.String, int, int)
*/
- //just here to satisfy the IMavenMarkerManager contract.
public IMarker addMarker(IResource resource, String type, String message, int lineNumber, int severity) {
return addMarker(resource, type, message, lineNumber, severity, false /*isTransient*/);
}
@@ -644,8 +643,26 @@ public class MavenMarkerManager implements IMavenMarkerManager {
}
public void deleteMarkers(IResource resource, String type) throws CoreException {
+ deleteMarkers(resource, true /*includeSubtypes*/, type);
+ }
+
+ public void deleteMarkers(IResource resource, boolean includeSubtypes, String type) throws CoreException {
if (resource != null && resource.exists()) {
- resource.deleteMarkers(type, true, IResource.DEPTH_INFINITE);
+ resource.deleteMarkers(type, includeSubtypes, IResource.DEPTH_INFINITE);
+ }
+ }
+
+ public void deleteMarkers(IResource resource, String type, int severity, String attrName, String attrValue)
+ throws CoreException {
+ if(resource == null || !resource.exists()) {
+ return;
+ }
+
+ IMarker[] markers = resource.findMarkers(type, false /*includeSubtypes*/, IResource.DEPTH_ZERO);
+ for(IMarker marker : markers) {
+ if(eq(severity, marker.getAttribute(IMarker.SEVERITY)) && eq(attrValue, marker.getAttribute(attrName))) {
+ marker.delete();
+ }
}
}
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/IMavenMarkerManager.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/IMavenMarkerManager.java
index 0c4f97f9..338142f3 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/IMavenMarkerManager.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/IMavenMarkerManager.java
@@ -42,10 +42,21 @@ public interface IMavenMarkerManager {
public IMarker addMarker(IResource resource, String type, String message, int lineNumber, int severity);
/**
- * Delete all Maven markers of the specified type from an IResource
+ * Delete all Maven markers of the specified type (including subtypes) from an IResource
*/
public void deleteMarkers(IResource resource, String type) throws CoreException;
-
+
+ /**
+ * Delete all Maven markers of the specified type from an IResource
+ */
+ public void deleteMarkers(IResource resource, boolean includeSubtypes, String type) throws CoreException;
+
+ /**
+ * Delete all Maven markers that have the specified type, severity and attribute from an IResource
+ */
+ public void deleteMarkers(IResource resource, String type, int severity, String attrName, String attrValue)
+ throws CoreException;
+
/**
* Transform an exception into an error marker on an IResource
*/
diff --git a/org.eclipse.m2e.maven.runtime/.classpath b/org.eclipse.m2e.maven.runtime/.classpath
index 8c8368da..55d9e06a 100644
--- a/org.eclipse.m2e.maven.runtime/.classpath
+++ b/org.eclipse.m2e.maven.runtime/.classpath
@@ -23,7 +23,7 @@
<classpathentry exported="true" kind="lib" path="jars/wagon-ahc-1.0.0.jar"/>
<classpathentry exported="true" kind="lib" path="jars/wagon-provider-api-1.0-beta-6.jar"/>
<classpathentry exported="true" kind="lib" path="jars/plexus-utils-2.0.4.jar"/>
- <classpathentry exported="true" kind="lib" path="jars/plexus-build-api-0.0.6.jar"/>
+ <classpathentry exported="true" kind="lib" path="jars/plexus-build-api-0.0.7-SNAPSHOT.jar"/>
<classpathentry exported="true" kind="lib" path="jars/async-http-client-1.3.4.jar"/>
<classpathentry exported="true" kind="lib" path="jars/netty-3.2.3.Final.jar"/>
<classpathentry exported="true" kind="lib" path="jars/aether-connector-http-1.7.0.jar"/>
diff --git a/org.eclipse.m2e.maven.runtime/META-INF/MANIFEST.MF b/org.eclipse.m2e.maven.runtime/META-INF/MANIFEST.MF
index 1e786633..7dd3c089 100644
--- a/org.eclipse.m2e.maven.runtime/META-INF/MANIFEST.MF
+++ b/org.eclipse.m2e.maven.runtime/META-INF/MANIFEST.MF
@@ -206,7 +206,7 @@ Bundle-ClassPath: jars/maven-embedder-3.0.jar,
jars/wagon-ahc-1.0.0.jar,
jars/wagon-provider-api-1.0-beta-6.jar,
jars/plexus-utils-2.0.4.jar,
- jars/plexus-build-api-0.0.6.jar,
+ jars/plexus-build-api-0.0.7-SNAPSHOT.jar,
jars/async-http-client-1.3.4.jar,
jars/netty-3.2.3.Final.jar,
jars/aether-connector-http-1.7.0.jar,
diff --git a/org.eclipse.m2e.maven.runtime/jars/plexus-build-api-0.0.6.jar b/org.eclipse.m2e.maven.runtime/jars/plexus-build-api-0.0.6.jar
deleted file mode 100644
index ab7f3fe1..00000000
--- a/org.eclipse.m2e.maven.runtime/jars/plexus-build-api-0.0.6.jar
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.m2e.maven.runtime/jars/plexus-build-api-0.0.7-SNAPSHOT.jar b/org.eclipse.m2e.maven.runtime/jars/plexus-build-api-0.0.7-SNAPSHOT.jar
new file mode 100644
index 00000000..d52893f3
--- /dev/null
+++ b/org.eclipse.m2e.maven.runtime/jars/plexus-build-api-0.0.7-SNAPSHOT.jar
Binary files differ
diff --git a/org.eclipse.m2e.tests.common/src/org/eclipse/m2e/tests/common/WorkspaceHelpers.java b/org.eclipse.m2e.tests.common/src/org/eclipse/m2e/tests/common/WorkspaceHelpers.java
index 379d1223..c04bedc9 100644
--- a/org.eclipse.m2e.tests.common/src/org/eclipse/m2e/tests/common/WorkspaceHelpers.java
+++ b/org.eclipse.m2e.tests.common/src/org/eclipse/m2e/tests/common/WorkspaceHelpers.java
@@ -169,6 +169,10 @@ public class WorkspaceHelpers {
return result;
}
+ public static List<IMarker> findWarningMarkers(IProject project) throws CoreException {
+ return findMarkers(project, IMarker.SEVERITY_WARNING);
+ }
+
public static List<IMarker> findErrorMarkers(IProject project) throws CoreException {
return findMarkers(project, IMarker.SEVERITY_ERROR);
}
@@ -178,17 +182,36 @@ public class WorkspaceHelpers {
Assert.assertEquals("Unexpected error markers " + toString(markers), 0, markers.size());
}
- public static void assertErrorMarker(String type, String message, Integer lineNumber, IProject project)
+ public static IMarker assertErrorMarker(String type, String message, Integer lineNumber, IProject project)
throws Exception {
+ return assertErrorMarker(type, message, lineNumber, project, "pom.xml");
+ }
+
+ public static IMarker assertErrorMarker(String type, String message, Integer lineNumber, IProject project,
+ String resourceRelativePath) throws Exception {
List<IMarker> errorMarkers = WorkspaceHelpers.findErrorMarkers(project);
Assert.assertNotNull(errorMarkers);
Assert.assertEquals(WorkspaceHelpers.toString(errorMarkers), 1, errorMarkers.size());
- assertErrorMarker(type, message, lineNumber, errorMarkers.get(0));
+ return assertErrorMarker(type, message, lineNumber, resourceRelativePath, errorMarkers.get(0));
+ }
+
+ public static IMarker assertWarningMarker(String type, String message, Integer lineNumber, IProject project,
+ String resourceRelativePath)
+ throws Exception {
+ List<IMarker> errorMarkers = WorkspaceHelpers.findWarningMarkers(project);
+ Assert.assertNotNull(errorMarkers);
+ Assert.assertEquals(WorkspaceHelpers.toString(errorMarkers), 1, errorMarkers.size());
+ return assertErrorMarker(type, message, lineNumber, resourceRelativePath, errorMarkers.get(0));
}
- public static void assertErrorMarker(String type, String message, Integer lineNumber, IMarker actual)
+ public static IMarker assertErrorMarker(String type, String message, Integer lineNumber, IMarker actual)
throws Exception {
- Assert.assertNotNull("Expected not null error marker", actual);
+ return assertErrorMarker(type, message, lineNumber, "pom.xml", actual);
+ }
+
+ public static IMarker assertErrorMarker(String type, String message, Integer lineNumber, String resourceRelativePath,
+ IMarker actual) throws Exception {
+ Assert.assertNotNull("Expected not null marker", actual);
String sMarker = toString(actual);
Assert.assertEquals(sMarker, type, actual.getType());
String actualMessage = actual.getAttribute(IMarker.MESSAGE, "");
@@ -199,5 +222,13 @@ public class WorkspaceHelpers {
if(type != null && type.startsWith(IMavenConstants.MARKER_ID)) {
Assert.assertEquals(sMarker, false, actual.getAttribute(IMarker.TRANSIENT));
}
+
+ if(resourceRelativePath == null) {
+ resourceRelativePath = "";
+ }
+ Assert.assertEquals("Marker not on the expected resource", resourceRelativePath, actual.getResource()
+ .getProjectRelativePath().toString());
+
+ return actual;
}
}

Back to the top