aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoberto Sanchez2013-01-30 15:49:08 (EST)
committerIgor Fedorenko2013-02-17 22:55:31 (EST)
commit26bd4382b76f7b51dbac2dd4a5934f9e5824e48e (patch)
treedf577f8632fcf75865110ac9471cb0f6cc3ebd38
parent03390fbd48f201fbc6e6d191f7dc2455539abc1d (diff)
downloadm2e-core-26bd4382b76f7b51dbac2dd4a5934f9e5824e48e.zip
m2e-core-26bd4382b76f7b51dbac2dd4a5934f9e5824e48e.tar.gz
m2e-core-26bd4382b76f7b51dbac2dd4a5934f9e5824e48e.tar.bz2
Order of classpath entries is modified when updating maven project
- I wrote 100% of the code; - I have the right to contribute the code to Eclipse; - The file header contains the appropriate License header
-rw-r--r--org.eclipse.m2e.jdt/src/org/eclipse/m2e/jdt/internal/AbstractJavaProjectConfigurator.java25
1 files changed, 11 insertions, 14 deletions
diff --git a/org.eclipse.m2e.jdt/src/org/eclipse/m2e/jdt/internal/AbstractJavaProjectConfigurator.java b/org.eclipse.m2e.jdt/src/org/eclipse/m2e/jdt/internal/AbstractJavaProjectConfigurator.java
index a58bc60..d936dc4 100644
--- a/org.eclipse.m2e.jdt/src/org/eclipse/m2e/jdt/internal/AbstractJavaProjectConfigurator.java
+++ b/org.eclipse.m2e.jdt/src/org/eclipse/m2e/jdt/internal/AbstractJavaProjectConfigurator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008-2010 Sonatype, Inc.
+ * Copyright (c) 2008-2013 Sonatype, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -174,12 +174,6 @@ public abstract class AbstractJavaProjectConfigurator extends AbstractProjectCon
}
protected void addJREClasspathContainer(IClasspathDescriptor classpath, String environmentId) {
- // remove existing JRE entry
- classpath.removeEntry(new ClasspathDescriptor.EntryFilter() {
- public boolean accept(IClasspathEntryDescriptor descriptor) {
- return JavaRuntime.JRE_CONTAINER.equals(descriptor.getPath().segment(0));
- }
- });
IClasspathEntry cpe;
IExecutionEnvironment executionEnvironment = getExecutionEnvironment(environmentId);
@@ -190,6 +184,15 @@ public abstract class AbstractJavaProjectConfigurator extends AbstractProjectCon
cpe = JavaCore.newContainerEntry(containerPath);
}
+ final IPath pathToKeep = cpe.getPath();
+ // remove existing JRE entry, only if the path is different from the entry we are going to add. See bug398121
+ classpath.removeEntry(new ClasspathDescriptor.EntryFilter() {
+ public boolean accept(IClasspathEntryDescriptor descriptor) {
+ return JavaRuntime.JRE_CONTAINER.equals(descriptor.getPath().segment(0))
+ && !descriptor.getPath().equals(pathToKeep);
+ }
+ });
+
classpath.addEntry(cpe);
}
@@ -204,15 +207,9 @@ public abstract class AbstractJavaProjectConfigurator extends AbstractProjectCon
}
protected void addMavenClasspathContainer(IClasspathDescriptor classpath) {
- // remove any old maven classpath container entries
- classpath.removeEntry(new ClasspathDescriptor.EntryFilter() {
- public boolean accept(IClasspathEntryDescriptor entry) {
- return MavenClasspathHelpers.isMaven2ClasspathContainer(entry.getPath());
- }
- });
- // add new entry
IClasspathEntry cpe = MavenClasspathHelpers.getDefaultContainerEntry();
+ // add new entry without removing existing entries first, see bug398121
classpath.addEntry(cpe);
}