Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIgor Fedorenko2011-08-18 12:34:07 -0400
committerIgor Fedorenko2011-08-18 12:34:07 -0400
commit133a9bad606ced21d81c4eecfc83baa18229c300 (patch)
tree637e5a64b3a3326d6c5b949a929cb2bed80bcc22
parent59c6ce0dc0bacc7d26f3200ea4657a4ec039184f (diff)
parent50195086b66fbedda87ba47617493e78eda4b346 (diff)
downloadm2e-core-133a9bad606ced21d81c4eecfc83baa18229c300.tar.gz
m2e-core-133a9bad606ced21d81c4eecfc83baa18229c300.tar.xz
m2e-core-133a9bad606ced21d81c4eecfc83baa18229c300.zip
Merge remote-tracking branch 'origin/master' into m2e-self-hosting
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenPomSelectionComponent.java14
-rw-r--r--org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/MarkerLocationService.java6
-rw-r--r--org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/lifecycle/LifecycleMappingProposal.java70
-rw-r--r--org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/composites/DependencyLabelProvider.java23
-rw-r--r--org.eclipse.m2e.launching/src/org/eclipse/m2e/internal/launch/MavenLaunchDelegate.java3
5 files changed, 91 insertions, 25 deletions
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenPomSelectionComponent.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenPomSelectionComponent.java
index 74e17928..d5fbc217 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenPomSelectionComponent.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenPomSelectionComponent.java
@@ -342,7 +342,19 @@ public class MavenPomSelectionComponent extends Composite {
}
}
} else {
- result.add(ia.getFiles().iterator().next());
+ //335383 find first non-snasphot version in case none is managed
+ boolean added = false;
+ for(IndexedArtifactFile file : ia.getFiles()) {
+ //what better means of recognizing snapshots?
+ if(file.version != null && !file.version.endsWith("-SNAPSHOT")) { //$NON-NLS-1$
+ added = true;
+ result.add(file);
+ break;
+ }
+ }
+ if (!added) {//just in case we deal with all snapshots..
+ result.add(ia.getFiles().iterator().next());
+ }
}
} else if(element instanceof IndexedArtifactFile) {
result.add((IndexedArtifactFile) element);
diff --git a/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/MarkerLocationService.java b/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/MarkerLocationService.java
index 34bbb8e8..482f2bc6 100644
--- a/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/MarkerLocationService.java
+++ b/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/MarkerLocationService.java
@@ -322,8 +322,10 @@ public class MarkerLocationService implements IMarkerLocationService, IEditorMar
List<Dependency> deps = dm.getDependencies();
if (deps != null) {
for (Dependency dep : deps) {
- //shall we be using geManagementkey() here? but it contains also the type, not only the gr+art ids..
- managed.put(dep.getGroupId() + ":" + dep.getArtifactId(), dep.getVersion()); //$NON-NLS-1$
+ if (dep.getVersion() != null) { //#335366
+ //shall we be using geManagementkey() here? but it contains also the type, not only the gr+art ids..
+ managed.put(dep.getGroupId() + ":" + dep.getArtifactId(), dep.getVersion()); //$NON-NLS-1$
+ }
}
}
}
diff --git a/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/lifecycle/LifecycleMappingProposal.java b/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/lifecycle/LifecycleMappingProposal.java
index 1555ff4a..6c14f625 100644
--- a/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/lifecycle/LifecycleMappingProposal.java
+++ b/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/lifecycle/LifecycleMappingProposal.java
@@ -15,6 +15,8 @@ package org.eclipse.m2e.editor.xml.internal.lifecycle;
import static org.eclipse.m2e.core.ui.internal.editing.PomEdits.performOnDOMDocument;
import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -23,6 +25,7 @@ import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.contentassist.ICompletionProposal;
import org.eclipse.jface.text.contentassist.ICompletionProposalExtension5;
@@ -36,14 +39,17 @@ import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IMarkerResolution;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.texteditor.MarkerAnnotation;
+import org.eclipse.ui.views.markers.WorkbenchMarkerResolution;
import org.eclipse.m2e.core.internal.IMavenConstants;
import org.eclipse.m2e.core.lifecyclemapping.model.PluginExecutionAction;
import org.eclipse.m2e.core.ui.internal.editing.LifecycleMappingOperation;
+import org.eclipse.m2e.core.ui.internal.editing.PomEdits.CompoundOperation;
import org.eclipse.m2e.core.ui.internal.editing.PomEdits.OperationTuple;
+import org.eclipse.m2e.core.ui.internal.editing.PomEdits.Operation;
import org.eclipse.m2e.editor.xml.internal.Messages;
-public class LifecycleMappingProposal implements ICompletionProposal, ICompletionProposalExtension5, IMarkerResolution {
+public class LifecycleMappingProposal extends WorkbenchMarkerResolution implements ICompletionProposal, ICompletionProposalExtension5 {
private static final Logger log = LoggerFactory.getLogger(LifecycleMappingProposal.class);
private IQuickAssistInvocationContext context;
@@ -66,9 +72,9 @@ public class LifecycleMappingProposal implements ICompletionProposal, ICompletio
public void apply(final IDocument doc) {
try {
if(PluginExecutionAction.ignore.equals(action)) {
- performIgnore();
+ performIgnore(new IMarker[] {marker});
} else {
- performOnDOMDocument(new OperationTuple(doc, createOperation()));
+ performOnDOMDocument(new OperationTuple(doc, createOperation(marker)));
}
} catch(IOException e) {
log.error("Error generating code in pom.xml", e); //$NON-NLS-1$
@@ -77,7 +83,7 @@ public class LifecycleMappingProposal implements ICompletionProposal, ICompletio
}
}
- private void performIgnore() throws IOException, CoreException {
+ private void performIgnore(IMarker[] marks) throws IOException, CoreException {
final IFile[] pomFile = new IFile[1];
PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
@@ -93,15 +99,19 @@ public class LifecycleMappingProposal implements ICompletionProposal, ICompletio
}
});
if(pomFile[0] != null) {
- performOnDOMDocument(new OperationTuple(pomFile[0], createOperation()));
+ List<LifecycleMappingOperation> lst = new ArrayList<LifecycleMappingOperation>();
+ for (IMarker m : marks) {
+ lst.add(createOperation(m));
+ }
+ performOnDOMDocument(new OperationTuple(pomFile[0], new CompoundOperation(lst.toArray(new Operation[0]))));
}
}
- private LifecycleMappingOperation createOperation() {
- String pluginGroupId = marker.getAttribute(IMavenConstants.MARKER_ATTR_GROUP_ID, ""); //$NON-NLS-1$
- String pluginArtifactId = marker.getAttribute(IMavenConstants.MARKER_ATTR_ARTIFACT_ID, ""); //$NON-NLS-1$
- String pluginVersion = marker.getAttribute(IMavenConstants.MARKER_ATTR_VERSION, ""); //$NON-NLS-1$
- String[] goals = new String[] { marker.getAttribute(IMavenConstants.MARKER_ATTR_GOAL, "")}; //$NON-NLS-1$
+ private LifecycleMappingOperation createOperation(IMarker mark) {
+ String pluginGroupId = mark.getAttribute(IMavenConstants.MARKER_ATTR_GROUP_ID, ""); //$NON-NLS-1$
+ String pluginArtifactId = mark.getAttribute(IMavenConstants.MARKER_ATTR_ARTIFACT_ID, ""); //$NON-NLS-1$
+ String pluginVersion = mark.getAttribute(IMavenConstants.MARKER_ATTR_VERSION, ""); //$NON-NLS-1$
+ String[] goals = new String[] { mark.getAttribute(IMavenConstants.MARKER_ATTR_GOAL, "")}; //$NON-NLS-1$
return new LifecycleMappingOperation(pluginGroupId, pluginArtifactId, pluginVersion, action, goals);
}
@@ -155,11 +165,45 @@ public class LifecycleMappingProposal implements ICompletionProposal, ICompletio
}
public void run(final IMarker marker) {
+ run(new IMarker[] {marker}, new NullProgressMonitor());
+ }
+
+ public String getDescription() {
+ // TODO Auto-generated method stub
+ return getDisplayString();
+ }
+
+ @Override
+ public IMarker[] findOtherMarkers(IMarker[] markers) {
+ List<IMarker> toRet = new ArrayList<IMarker>();
+
+ for (IMarker mark : markers) {
+ if (mark == this.marker) {
+ continue;
+ }
+ try {
+ if (mark.getType().equals(this.marker.getType()) && mark.getResource().equals(this.marker.getResource())) {
+ toRet.add(mark);
+ }
+ } catch(CoreException e) {
+ log.error(e.getMessage(), e);
+ }
+ }
+ return toRet.toArray(new IMarker[0]);
+
+ }
+
+ @Override
+ public void run(IMarker[] markers, IProgressMonitor monitor) {
try {
if(PluginExecutionAction.ignore.equals(action)) {
- performIgnore();
+ performIgnore(markers);
} else {
- performOnDOMDocument(new OperationTuple((IFile) marker.getResource(), createOperation()));
+ List<LifecycleMappingOperation> lst = new ArrayList<LifecycleMappingOperation>();
+ for (IMarker m : markers) {
+ lst.add(createOperation(m));
+ }
+ performOnDOMDocument(new OperationTuple((IFile) marker.getResource(), new CompoundOperation(lst.toArray(new Operation[0]))));
}
} catch(IOException e) {
log.error("Error generating code in pom.xml", e); //$NON-NLS-1$
@@ -167,4 +211,6 @@ public class LifecycleMappingProposal implements ICompletionProposal, ICompletio
log.error(e.getMessage(), e);
}
}
+
+
} \ No newline at end of file
diff --git a/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/composites/DependencyLabelProvider.java b/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/composites/DependencyLabelProvider.java
index 451cc001..22fc6e18 100644
--- a/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/composites/DependencyLabelProvider.java
+++ b/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/composites/DependencyLabelProvider.java
@@ -89,10 +89,11 @@ public class DependencyLabelProvider extends LabelProvider implements IColorProv
return null;
}
- private String findManagedVersion(DependenciesComposite.Dependency dep) {
+ private String[] findManaged(DependenciesComposite.Dependency dep) {
if (pomEditor != null) {
MavenProject mp = pomEditor.getMavenProject();
String version = null;
+ String scope = null;
if(mp != null) {
String id = mp.getGroupId() + ":" + mp.getArtifactId() + ":" + mp.getVersion();
DependencyManagement dm = mp.getDependencyManagement();
@@ -104,10 +105,11 @@ public class DependencyLabelProvider extends LabelProvider implements IColorProv
if (location != null) {
if (id.equals(location.getSource().getModelId())) {
version = d.getVersion();
+ scope = d.getScope();
break;
}
}
- return d.getVersion();
+ return new String [] {d.getVersion(), d.getScope()};
}
}
}
@@ -117,13 +119,14 @@ public class DependencyLabelProvider extends LabelProvider implements IColorProv
String modelGroupId = modelDep.getGroupId();
String modelArtifactId = modelDep.getArtifactId();
String modelVersion = modelDep.getVersion();
+ String modelScope = modelDep.getScope();
if (modelGroupId != null && modelGroupId.equals(dep.groupId) && modelArtifactId != null
&& modelArtifactId.equals(dep.artifactId)) {
if (version != null && (modelVersion == null || modelVersion.contains("${"))) {
//prefer the resolved version to the model one if the model version as expressions..
- return version;
+ return new String[] {version, modelScope == null ? scope : modelScope};
}
- return modelVersion;
+ return new String[] {modelVersion, modelScope == null ? scope : modelScope};
}
}
}
@@ -134,9 +137,13 @@ public class DependencyLabelProvider extends LabelProvider implements IColorProv
if(element instanceof DependenciesComposite.Dependency) {
StyledString ss = new StyledString(getText(element));
DependenciesComposite.Dependency dep = (DependenciesComposite.Dependency) element;
- String version = findManagedVersion(dep);
- if (version != null) {
- ss.append(NLS.bind(Messages.DependencyLabelProvider_0, version), StyledString.DECORATIONS_STYLER);
+ String[] managed = findManaged(dep);
+ if (managed != null && managed[0] != null) {
+ String man = managed[0];
+ if (managed[1] != null && !Artifact.SCOPE_COMPILE.equals(managed[1])) {
+ man = man + "," + managed[1];
+ }
+ ss.append(NLS.bind(Messages.DependencyLabelProvider_0, man), StyledString.DECORATIONS_STYLER);
}
return ss;
}
@@ -169,7 +176,7 @@ public class DependencyLabelProvider extends LabelProvider implements IColorProv
public Image getImage(Object element) {
if(element instanceof DependenciesComposite.Dependency) {
DependenciesComposite.Dependency dependency = (DependenciesComposite.Dependency) element;
- boolean isManaged = showManagedOverlay && findManagedVersion(dependency) != null;
+ boolean isManaged = showManagedOverlay && findManaged(dependency) != null;
return getImage(dependency.groupId, dependency.artifactId, dependency.version, isManaged);
} else if (element instanceof org.apache.maven.model.Dependency) {
diff --git a/org.eclipse.m2e.launching/src/org/eclipse/m2e/internal/launch/MavenLaunchDelegate.java b/org.eclipse.m2e.launching/src/org/eclipse/m2e/internal/launch/MavenLaunchDelegate.java
index 03639a46..00d965af 100644
--- a/org.eclipse.m2e.launching/src/org/eclipse/m2e/internal/launch/MavenLaunchDelegate.java
+++ b/org.eclipse.m2e.launching/src/org/eclipse/m2e/internal/launch/MavenLaunchDelegate.java
@@ -21,7 +21,6 @@ import java.util.List;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.debug.core.DebugEvent;
@@ -68,7 +67,7 @@ public class MavenLaunchDelegate extends JavaLaunchDelegate implements MavenLaun
m2conf.addArchiveEntry(MavenLaunchUtils.getCliResolver(runtime));
}
MavenLaunchUtils.addUserComponents(configuration, m2conf);
- runtime.createLauncherConfiguration(m2conf, new NullProgressMonitor());
+ runtime.createLauncherConfiguration(m2conf, monitor);
File state = MavenPluginActivator.getDefault().getStateLocation().toFile();
try {

Back to the top