Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMickael Istria2019-05-10 16:54:55 -0400
committerMickael Istria2019-05-13 03:38:50 -0400
commitfe5d8590794dc4a35a2eb12d9a1d694e7fb8bb10 (patch)
treeabe9eb6b1c9a84233296bba836c35e4ec0b90334
parent15d9b8d7181c39369615107519830590b6d7a2b4 (diff)
downloadm2e-core-fe5d8590794dc4a35a2eb12d9a1d694e7fb8bb10.tar.gz
m2e-core-fe5d8590794dc4a35a2eb12d9a1d694e7fb8bb10.tar.xz
m2e-core-fe5d8590794dc4a35a2eb12d9a1d694e7fb8bb10.zip
Bug 515668 - Fix bug in project resolution
Some useless and erroneous check prevents from reloading already parsed project even when one of their dependencies is updated. Change-Id: If9ebe1721209cad8df89a2852fa2fc83a24861f4 Signed-off-by: Mickael Istria <mistria@redhat.com>
-rw-r--r--org.eclipse.m2e.core.tests/resources/projects/dependency/dependency/.classpath6
-rw-r--r--org.eclipse.m2e.core.tests/resources/projects/dependency/dependency/.project23
-rw-r--r--org.eclipse.m2e.core.tests/resources/projects/dependency/dependency/pom.xml7
-rw-r--r--org.eclipse.m2e.core.tests/resources/projects/dependency/dependent/.classpath6
-rw-r--r--org.eclipse.m2e.core.tests/resources/projects/dependency/dependent/.project23
-rw-r--r--org.eclipse.m2e.core.tests/resources/projects/dependency/dependent/pom.xml16
-rw-r--r--org.eclipse.m2e.core.tests/src/org/eclipse/m2e/core/internal/project/registry/RegistryTest.java26
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/registry/ProjectRegistryManager.java6
8 files changed, 103 insertions, 10 deletions
diff --git a/org.eclipse.m2e.core.tests/resources/projects/dependency/dependency/.classpath b/org.eclipse.m2e.core.tests/resources/projects/dependency/dependency/.classpath
new file mode 100644
index 00000000..464509f4
--- /dev/null
+++ b/org.eclipse.m2e.core.tests/resources/projects/dependency/dependency/.classpath
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"/>
+ <classpathentry kind="output" path="target/classes"/>
+</classpath>
diff --git a/org.eclipse.m2e.core.tests/resources/projects/dependency/dependency/.project b/org.eclipse.m2e.core.tests/resources/projects/dependency/dependency/.project
new file mode 100644
index 00000000..b5fc4ecc
--- /dev/null
+++ b/org.eclipse.m2e.core.tests/resources/projects/dependency/dependency/.project
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>dependency</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.m2e.core.maven2Builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.m2e.core.maven2Nature</nature>
+ </natures>
+</projectDescription>
diff --git a/org.eclipse.m2e.core.tests/resources/projects/dependency/dependency/pom.xml b/org.eclipse.m2e.core.tests/resources/projects/dependency/dependency/pom.xml
new file mode 100644
index 00000000..c22fb760
--- /dev/null
+++ b/org.eclipse.m2e.core.tests/resources/projects/dependency/dependency/pom.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?><project>
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.eclipse.m2e.core.test.registrymanager</groupId>
+ <artifactId>dependency</artifactId>
+ <version>0.0.1</version>
+</project>
diff --git a/org.eclipse.m2e.core.tests/resources/projects/dependency/dependent/.classpath b/org.eclipse.m2e.core.tests/resources/projects/dependency/dependent/.classpath
new file mode 100644
index 00000000..464509f4
--- /dev/null
+++ b/org.eclipse.m2e.core.tests/resources/projects/dependency/dependent/.classpath
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"/>
+ <classpathentry kind="output" path="target/classes"/>
+</classpath>
diff --git a/org.eclipse.m2e.core.tests/resources/projects/dependency/dependent/.project b/org.eclipse.m2e.core.tests/resources/projects/dependency/dependent/.project
new file mode 100644
index 00000000..e2eff98c
--- /dev/null
+++ b/org.eclipse.m2e.core.tests/resources/projects/dependency/dependent/.project
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>dependent</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.m2e.core.maven2Builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.m2e.core.maven2Nature</nature>
+ </natures>
+</projectDescription>
diff --git a/org.eclipse.m2e.core.tests/resources/projects/dependency/dependent/pom.xml b/org.eclipse.m2e.core.tests/resources/projects/dependency/dependent/pom.xml
new file mode 100644
index 00000000..7b2cf9ec
--- /dev/null
+++ b/org.eclipse.m2e.core.tests/resources/projects/dependency/dependent/pom.xml
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?><project>
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.eclipse.m2e.core.test.registrymanager</groupId>
+ <artifactId>dependent</artifactId>
+ <version>0.0.1</version>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.eclipse.m2e.core.test.registrymanager</groupId>
+ <artifactId>dependency</artifactId>
+ <version>0.0.1</version>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/org.eclipse.m2e.core.tests/src/org/eclipse/m2e/core/internal/project/registry/RegistryTest.java b/org.eclipse.m2e.core.tests/src/org/eclipse/m2e/core/internal/project/registry/RegistryTest.java
index 1d39f441..56022c08 100644
--- a/org.eclipse.m2e.core.tests/src/org/eclipse/m2e/core/internal/project/registry/RegistryTest.java
+++ b/org.eclipse.m2e.core.tests/src/org/eclipse/m2e/core/internal/project/registry/RegistryTest.java
@@ -12,19 +12,20 @@
package org.eclipse.m2e.core.internal.project.registry;
import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
import java.util.Collections;
-import org.junit.Assert;
-import org.junit.Test;
-
+import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
-
import org.eclipse.m2e.core.embedder.ArtifactKey;
import org.eclipse.m2e.core.internal.MavenPluginActivator;
import org.eclipse.m2e.core.project.IMavenProjectFacade;
import org.eclipse.m2e.tests.common.AbstractMavenProjectTestCase;
+import org.junit.Assert;
+import org.junit.Test;
public class RegistryTest extends AbstractMavenProjectTestCase {
@@ -56,4 +57,21 @@ public class RegistryTest extends AbstractMavenProjectTestCase {
assertEquals(Collections.singleton(project.getFile("pom.xml")), registry.getDependents(parentCapability, false));
}
+ @Test
+ public void testMultiRefreshKeepsCapabilities() throws IOException, CoreException, InterruptedException {
+ IProject dependentProject = createExisting("dependent", "resources/projects/dependency/dependent", true);
+ IProject dependencyProject = createExisting("dependency", "resources/projects/dependency/dependency", true);
+ waitForJobsToComplete(monitor);
+ ProjectRegistryManager registryManager = MavenPluginActivator.getDefault().getMavenProjectManagerImpl();
+ Collection<IFile> pomFiles = new ArrayList<>(2);
+ pomFiles.add(dependentProject.getFile("pom.xml"));
+ pomFiles.add(dependencyProject.getFile("pom.xml"));
+ MutableProjectRegistry state = MavenPluginActivator.getDefault().getMavenProjectManagerImpl().newMutableProjectRegistry();
+ state.clear();
+ registryManager.getMaven().execute(false, false, (context, aMonitor) -> {
+ registryManager.refresh(state, pomFiles, aMonitor);
+ return null;
+ }, monitor);
+ Assert.assertNotEquals(Collections.emptyMap(), state.requiredCapabilities);
+ }
}
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 a6b8f455..96b380cb 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
@@ -474,7 +474,6 @@ public class ProjectRegistryManager {
context.forcePomFiles(allProcessedPoms);
// phase 2: resolve project dependencies
- Set<IFile> secondPhaseProcessed = new HashSet<IFile>();
while(!context.isEmpty()) {
if(monitor.isCanceled()) {
throw new OperationCanceledException();
@@ -486,11 +485,6 @@ public class ProjectRegistryManager {
final IFile pom = context.pop();
- if(!secondPhaseProcessed.add(pom)) {
- // because workspace contents is fully known at this point, each project needs to be resolved at most once
- continue;
- }
-
MavenProjectFacade newFacade = null;
if(pom.isAccessible() && pom.getProject().hasNature(IMavenConstants.NATURE_ID)) {
newFacade = newState.getProjectFacade(pom);

Back to the top