Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Tanasenko2014-06-07 10:57:52 -0400
committerAnton Tanasenko2014-10-01 04:31:31 -0400
commitb6c1317a60bb70b5abc2cfcedd011bfa8f578d45 (patch)
tree27ab37cd916d6b5cecfeba45bc19ef4fe00b9d0f /org.eclipse.m2e.core
parentd6a903b7e4886d0ae8d24b4240d0fb93d78d51bb (diff)
downloadm2e-core-b6c1317a60bb70b5abc2cfcedd011bfa8f578d45.tar.gz
m2e-core-b6c1317a60bb70b5abc2cfcedd011bfa8f578d45.tar.xz
m2e-core-b6c1317a60bb70b5abc2cfcedd011bfa8f578d45.zip
436929 - Changes in imported dependencyManagement poms do not cause
refresh in dependent projects Change-Id: I5b5f1d0b848bdad1a9d072e104df0c7b32ceada3 Signed-off-by: Anton Tanasenko <atg.sleepless@gmail.com>
Diffstat (limited to 'org.eclipse.m2e.core')
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/registry/DefaultMavenDependencyResolver.java21
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/registry/MavenCapability.java9
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/registry/MavenRequiredCapability.java5
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/registry/ProjectRegistryManager.java27
4 files changed, 56 insertions, 6 deletions
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/registry/DefaultMavenDependencyResolver.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/registry/DefaultMavenDependencyResolver.java
index 6728d013..847d7864 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/registry/DefaultMavenDependencyResolver.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/registry/DefaultMavenDependencyResolver.java
@@ -22,6 +22,7 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.execution.MavenExecutionResult;
+import org.apache.maven.model.DependencyManagement;
import org.apache.maven.model.Plugin;
import org.apache.maven.project.DependencyResolutionResult;
import org.apache.maven.project.MavenProject;
@@ -104,10 +105,28 @@ public class DefaultMavenDependencyResolver extends AbstractMavenDependencyResol
log.debug("Resolved dependencies for {} in {} ms", facade.toString(), System.currentTimeMillis() - start); //$NON-NLS-1$
}
- public static void addParentRequirements(Set<RequiredCapability> requirements, MavenProject mavenProject) {
+ public static void addProjectStructureRequirements(Set<RequiredCapability> requirements, MavenProject mavenProject) {
+ // parent requirement
Artifact parentArtifact = mavenProject.getParentArtifact();
if(parentArtifact != null) {
requirements.add(MavenRequiredCapability.createResolvedMavenParent(new ArtifactKey(parentArtifact)));
}
+
+ // imported dependency management requirements
+ while(mavenProject != null) {
+ DependencyManagement dependencyManagement = mavenProject.getOriginalModel().getDependencyManagement();
+ if(dependencyManagement != null) {
+ for(org.apache.maven.model.Dependency managedDep : dependencyManagement.getDependencies()) {
+ if("pom".equals(managedDep.getType()) && "import".equals(managedDep.getScope())) { //$NON-NLS-1$ $NON-NLS-2$
+ ArtifactKey dependencyKey = new ArtifactKey(managedDep.getGroupId(), managedDep.getArtifactId(),
+ managedDep.getVersion(), null);
+ requirements.add(MavenRequiredCapability.createMavenArtifactImport(dependencyKey));
+ }
+ }
+ }
+
+ // add imports from all ancestors
+ mavenProject = mavenProject.getParent();
+ }
}
}
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/registry/MavenCapability.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/registry/MavenCapability.java
index 20943f9c..782f1783 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/registry/MavenCapability.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/registry/MavenCapability.java
@@ -29,6 +29,11 @@ public class MavenCapability extends Capability {
public static final String NS_MAVEN_ARTIFACT = "maven-artifact"; //$NON-NLS-1$
/**
+ * Import-scoped Maven dependency as defined in <dependencyManagement/> pom.xml element.
+ */
+ public static final String NS_MAVEN_ARTIFACT_IMPORT = "maven-artifact-import"; //$NON-NLS-1$
+
+ /**
* Maven parent dependency as defined in <parent/> pom.xml element.
*/
public static final String NS_MAVEN_PARENT = "maven-parent"; //$NON-NLS-1$
@@ -69,6 +74,10 @@ public class MavenCapability extends Capability {
return new MavenCapability(NS_MAVEN_ARTIFACT, getId(key), key.getVersion());
}
+ public static MavenCapability createMavenArtifactImport(ArtifactKey key) {
+ return new MavenCapability(NS_MAVEN_ARTIFACT_IMPORT, getId(key), key.getVersion());
+ }
+
public static MavenCapability createMavenParent(ArtifactKey key) {
return new MavenCapability(NS_MAVEN_PARENT, getId(key), key.getVersion());
}
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/registry/MavenRequiredCapability.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/registry/MavenRequiredCapability.java
index bb8b976d..6f5cc3fa 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/registry/MavenRequiredCapability.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/registry/MavenRequiredCapability.java
@@ -54,6 +54,11 @@ public class MavenRequiredCapability extends RequiredCapability {
scope, optional, false);
}
+ public static MavenRequiredCapability createMavenArtifactImport(ArtifactKey key) {
+ return new MavenRequiredCapability(MavenCapability.NS_MAVEN_ARTIFACT_IMPORT, MavenCapability.getId(key),
+ key.getVersion(), "import", false, false); //$NON-NLS-1$
+ }
+
public static MavenRequiredCapability createMavenParent(ArtifactKey key) {
return new MavenRequiredCapability(MavenCapability.NS_MAVEN_PARENT, MavenCapability.getId(key), key.getVersion(),
null, false, false);
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/registry/ProjectRegistryManager.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/registry/ProjectRegistryManager.java
index 874e85ce..0c3d0518 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/registry/ProjectRegistryManager.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/registry/ProjectRegistryManager.java
@@ -330,10 +330,13 @@ public class ProjectRegistryManager {
if(installedArtifacts.add(artifact)) {
refresh.addAll(newState.getVersionedDependents(MavenCapability.createMavenParent(artifact), true));
refresh.addAll(newState.getVersionedDependents(MavenCapability.createMavenArtifact(artifact), true));
+ refresh.addAll(newState.getVersionedDependents(MavenCapability.createMavenArtifactImport(artifact), true));
}
if(installedArtifacts.add(baseArtifact)) {
refresh.addAll(newState.getVersionedDependents(MavenCapability.createMavenParent(baseArtifact), true));
refresh.addAll(newState.getVersionedDependents(MavenCapability.createMavenArtifact(baseArtifact), true));
+ refresh
+ .addAll(newState.getVersionedDependents(MavenCapability.createMavenArtifactImport(baseArtifact), true));
}
if(!refresh.isEmpty()) {
log.debug("Automatic refresh. artifact={}/{}. projects={}", new Object[] {baseArtifact, artifact, refresh});
@@ -384,6 +387,11 @@ public class ProjectRegistryManager {
// refresh old child modules
MavenCapability mavenParentCapability = MavenCapability.createMavenParent(oldFacade.getArtifactKey());
context.forcePomFiles(newState.getVersionedDependents(mavenParentCapability, true));
+
+ // refresh projects that import dependencyManagement from this one
+ MavenCapability mavenArtifactImportCapability = MavenCapability.createMavenArtifactImport(oldFacade
+ .getArtifactKey());
+ context.forcePomFiles(newState.getVersionedDependents(mavenArtifactImportCapability, true));
}
newFacade = readMavenProjectFacade(pom, context, newState, monitor);
@@ -392,6 +400,10 @@ public class ProjectRegistryManager {
if(oldFacade != null) {
MavenCapability mavenParentCapability = MavenCapability.createMavenParent(oldFacade.getArtifactKey());
context.forcePomFiles(newState.getDependents(mavenParentCapability, true));
+
+ MavenCapability mavenArtifactImportCapability = MavenCapability.createMavenArtifactImport(oldFacade
+ .getArtifactKey());
+ context.forcePomFiles(newState.getVersionedDependents(mavenArtifactImportCapability, true));
}
}
@@ -402,6 +414,11 @@ public class ProjectRegistryManager {
MavenCapability mavenParentCapability = MavenCapability.createMavenParent(newFacade.getArtifactKey());
context.forcePomFiles(newState.getVersionedDependents(mavenParentCapability, true));
+ // refresh projects that import dependencyManagement from this one
+ MavenCapability mavenArtifactImportCapability = MavenCapability.createMavenArtifactImport(newFacade
+ .getArtifactKey());
+ context.forcePomFiles(newState.getVersionedDependents(mavenArtifactImportCapability, true));
+
Set<Capability> capabilities = new LinkedHashSet<Capability>();
capabilities.add(mavenParentCapability);
capabilities.add(MavenCapability.createMavenArtifact(newFacade.getArtifactKey()));
@@ -410,12 +427,14 @@ public class ProjectRegistryManager {
originalCapabilities.put(pom, oldCapabilities);
}
+ MavenProject mavenProject = getMavenProject(newFacade);
Set<RequiredCapability> requirements = new LinkedHashSet<RequiredCapability>();
- DefaultMavenDependencyResolver.addParentRequirements(requirements, getMavenProject(newFacade));
+ DefaultMavenDependencyResolver.addProjectStructureRequirements(requirements, mavenProject);
Set<RequiredCapability> oldRequirements = newState.setRequirements(pom, requirements);
if(!originalRequirements.containsKey(pom)) {
originalRequirements.put(pom, oldRequirements);
}
+
}
// at this point project facade and project capabilities/requirements are inconsistent in the state
@@ -502,13 +521,12 @@ public class ProjectRegistryManager {
capabilities.add(mavenParentCapability); // TODO consider packaging
// maven projects always have these requirements
- DefaultMavenDependencyResolver.addParentRequirements(requirements, getMavenProject(newFacade));
+ DefaultMavenDependencyResolver.addProjectStructureRequirements(requirements, getMavenProject(newFacade));
AbstractMavenDependencyResolver resolver = getMavenDependencyResolver(newFacade, monitor);
resolver.setContextProjectRegistry(newState);
try {
- resolver.resolveProjectDependencies(newFacade, maven.getExecutionContext().getExecutionRequest(), capabilities,
- requirements, monitor);
+ resolver.resolveProjectDependencies(newFacade, capabilities, requirements, monitor);
} finally {
resolver.setContextProjectRegistry(null);
}
@@ -568,7 +586,6 @@ public class ProjectRegistryManager {
context.forcePomFiles(newState.getVersionedDependents(capability, true));
}
}
-
}
private void setupLifecycleMapping(MutableProjectRegistry newState, IProgressMonitor monitor,

Back to the top