Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIgor Fedorenko2011-08-01 04:21:05 -0400
committerIgor Fedorenko2011-08-01 04:21:05 -0400
commitbfff4a0509d7ec9bdb813ca40e7bfb16372548f5 (patch)
treea3fe63a244e8ccd76cd7c6c996bc651823a05686
parent74e41f5cadf4d515ccb47e38a8656a7b111ef457 (diff)
downloadm2e-core-bfff4a0509d7ec9bdb813ca40e7bfb16372548f5.tar.gz
m2e-core-bfff4a0509d7ec9bdb813ca40e7bfb16372548f5.tar.xz
m2e-core-bfff4a0509d7ec9bdb813ca40e7bfb16372548f5.zip
352411 - Dependency Hierarchy doesn't resolve dependencies from workspace
Use project workspace dependency resolution on/off configuration when calculating dependency hierarchy for main pom.xml files. Workspace dependency resolution is off for all other pom.xml files. Signed-off-by: Igor Fedorenko <igor@ifedorenko.com>
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/embedder/MavenModelManager.java36
-rw-r--r--org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/pom/MavenPomEditor.java11
2 files changed, 38 insertions, 9 deletions
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/embedder/MavenModelManager.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/embedder/MavenModelManager.java
index 0e848b7b..3d4b5ed5 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/embedder/MavenModelManager.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/embedder/MavenModelManager.java
@@ -45,6 +45,7 @@ import org.eclipse.osgi.util.NLS;
import org.apache.maven.RepositoryUtils;
import org.apache.maven.artifact.Artifact;
+import org.apache.maven.execution.MavenExecutionRequest;
import org.apache.maven.model.DependencyManagement;
import org.apache.maven.project.MavenProject;
@@ -158,6 +159,10 @@ public class MavenModelManager {
}
}
+ /**
+ * @deprecated use {@link #readDependencyTree(IMavenProjectFacade, MavenProject, String, IProgressMonitor)}, which
+ * supports workspace dependency resolution
+ */
public synchronized DependencyNode readDependencyTree(IFile file, String classpath,
IProgressMonitor monitor) throws CoreException {
monitor.setTaskName(Messages.MavenModelManager_monitor_reading);
@@ -166,13 +171,30 @@ public class MavenModelManager {
return readDependencyTree(mavenProject, classpath, monitor);
}
- public synchronized DependencyNode readDependencyTree(MavenProject mavenProject,
- String classpath, IProgressMonitor monitor) throws CoreException {
+ /**
+ * @deprecated use {@link #readDependencyTree(IMavenProjectFacade, MavenProject, String, IProgressMonitor)}, which
+ * supports workspace dependency resolution
+ */
+ public DependencyNode readDependencyTree(MavenProject mavenProject, String classpath, IProgressMonitor monitor)
+ throws CoreException {
+ return readDependencyTree(null, mavenProject, classpath, monitor);
+ }
+
+ public synchronized DependencyNode readDependencyTree(IMavenProjectFacade context, MavenProject mavenProject,
+ String scope, IProgressMonitor monitor) throws CoreException {
monitor.setTaskName(Messages.MavenModelManager_monitor_building);
IMaven maven = MavenPlugin.getMaven();
- DefaultRepositorySystemSession session = new DefaultRepositorySystemSession(maven.createSession(
- maven.createExecutionRequest(monitor), mavenProject).getRepositorySession());
+
+ MavenExecutionRequest executionRequest;
+ if(context != null) {
+ executionRequest = MavenPlugin.getMavenProjectRegistry().createExecutionRequest(context, monitor);
+ } else {
+ executionRequest = maven.createExecutionRequest(monitor);
+ }
+
+ DefaultRepositorySystemSession session = new DefaultRepositorySystemSession(maven.createSession(executionRequest,
+ mavenProject).getRepositorySession());
DependencyGraphTransformer transformer = new ChainedDependencyGraphTransformer(new JavaEffectiveScopeCalculator(),
new NearestVersionConflictResolver());
@@ -211,14 +233,14 @@ public class MavenModelManager {
Collection<String> scopes = new HashSet<String>();
Collections.addAll(scopes, Artifact.SCOPE_SYSTEM, Artifact.SCOPE_COMPILE, Artifact.SCOPE_PROVIDED,
Artifact.SCOPE_RUNTIME, Artifact.SCOPE_TEST);
- if(Artifact.SCOPE_COMPILE.equals(classpath)) {
+ if(Artifact.SCOPE_COMPILE.equals(scope)) {
scopes.remove(Artifact.SCOPE_COMPILE);
scopes.remove(Artifact.SCOPE_SYSTEM);
scopes.remove(Artifact.SCOPE_PROVIDED);
- } else if(Artifact.SCOPE_RUNTIME.equals(classpath)) {
+ } else if(Artifact.SCOPE_RUNTIME.equals(scope)) {
scopes.remove(Artifact.SCOPE_COMPILE);
scopes.remove(Artifact.SCOPE_RUNTIME);
- } else if(Artifact.SCOPE_COMPILE_PLUS_RUNTIME.equals(classpath)) {
+ } else if(Artifact.SCOPE_COMPILE_PLUS_RUNTIME.equals(scope)) {
scopes.remove(Artifact.SCOPE_COMPILE);
scopes.remove(Artifact.SCOPE_SYSTEM);
scopes.remove(Artifact.SCOPE_PROVIDED);
diff --git a/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/pom/MavenPomEditor.java b/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/pom/MavenPomEditor.java
index 324f3bdb..aec564e3 100644
--- a/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/pom/MavenPomEditor.java
+++ b/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/pom/MavenPomEditor.java
@@ -38,6 +38,7 @@ import org.eclipse.core.runtime.IExtensionPoint;
import org.eclipse.core.runtime.IExtensionRegistry;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
@@ -62,7 +63,6 @@ import org.eclipse.m2e.core.project.IMavenProjectChangedListener;
import org.eclipse.m2e.core.project.IMavenProjectFacade;
import org.eclipse.m2e.core.project.MavenProjectChangedEvent;
import org.eclipse.m2e.core.ui.internal.M2EUIPluginActivator;
-import org.eclipse.m2e.core.ui.internal.actions.OpenPomAction.MavenPathStorageEditorInput;
import org.eclipse.m2e.core.ui.internal.actions.OpenPomAction.MavenStorageEditorInput;
import org.eclipse.m2e.core.ui.internal.actions.SelectionUtil;
import org.eclipse.m2e.editor.MavenEditorPlugin;
@@ -692,7 +692,14 @@ public class MavenPomEditor extends FormEditor implements IResourceChangeListene
log.error("Unable to read maven project. Dependencies not updated."); //$NON-NLS-1$
return null;
}
- DependencyNode root = MavenPlugin.getMavenModelManager().readDependencyTree(mavenProject, classpath, monitor);
+
+ IMavenProjectFacade facade = null;
+ if(pomFile != null && new Path(IMavenConstants.POM_FILE_NAME).equals(pomFile.getProjectRelativePath())) {
+ facade = MavenPlugin.getMavenProjectRegistry().getProject(pomFile.getProject());
+ }
+
+ DependencyNode root = MavenPlugin.getMavenModelManager().readDependencyTree(facade, mavenProject, classpath,
+ monitor);
root.setData("LEVEL", "ROOT");
for (DependencyNode nd : root.getChildren()) {
nd.setData("LEVEL", "DIRECT");

Back to the top