Browse files

Modified container reordering so that JRE comes before Maven. The

opposite created some java compilation errors with generics for
instance.
  • Loading branch information...
1 parent e0253b7 commit ea97119069c7b0ddff37a631495b2ab36a094781 @dcardin dcardin committed Dec 15, 2011
View
19 org.maven.ide.eclipse.scala/src/org/maven/ide/eclipse/scala/ScalaProjectConfigurator.java
@@ -25,6 +25,7 @@
import org.eclipse.m2e.jdt.IClasspathDescriptor;
import org.eclipse.m2e.jdt.IClasspathEntryDescriptor;
import org.eclipse.m2e.jdt.IJavaProjectConfigurator;
+import org.eclipse.m2e.jdt.internal.MavenClasspathHelpers;
import org.eclipse.m2e.core.project.IMavenProjectFacade;
import org.eclipse.m2e.core.project.configurator.AbstractProjectConfigurator;
import org.eclipse.m2e.core.project.configurator.ProjectConfigurationRequest;
@@ -237,26 +238,40 @@ private void sortContainerScalaJre(IProject project, IProgressMonitor monitor) t
int posScalaContainer = -1;
int posJreContainer = -1;
+ int posMavenContainer = -1;
+
for (int i = 0; i < rawClasspath.length; i++) {
IClasspathEntry e = rawClasspath[i];
if (IClasspathEntry.CPE_CONTAINER == e.getEntryKind()) {
// "org.eclipse.jdt.launching.JRE_CONTAINER"
if (JavaRuntime.JRE_CONTAINER.equals(e.getPath().segment(0))) {
posJreContainer = i;
}
- // ""
if (scalaLibId().equals(e.getPath().segment(0))) {
posScalaContainer = i;
}
+ if (e.equals(MavenClasspathHelpers.getDefaultContainerEntry()))
+ posMavenContainer = i;
}
}
+
+ if (posMavenContainer != -1 && posJreContainer != -1 && posJreContainer > posMavenContainer) {
+ // swap position to have jre before maven
+ IClasspathEntry tmp = rawClasspath[posMavenContainer];
+ rawClasspath[posMavenContainer] = rawClasspath[posJreContainer];
+ rawClasspath[posJreContainer]= tmp;
+ javaProject.setRawClasspath(rawClasspath, monitor);
+ }
+
if (posScalaContainer != -1 && posJreContainer != -1 && posScalaContainer > posJreContainer) {
// swap position to have scalaContainer first
IClasspathEntry tmp = rawClasspath[posScalaContainer];
rawClasspath[posScalaContainer] = rawClasspath[posJreContainer];
rawClasspath[posJreContainer]= tmp;
javaProject.setRawClasspath(rawClasspath, monitor);
- } else if (posScalaContainer == -1) {
+ }
+
+ if (posScalaContainer == -1) {
System.out.println("no scala container !!!");
// rawClasspath[posScalaContainer] = rawClasspath[posJreContainer];
// rawClasspath[posJreContainer]= tmp;

0 comments on commit ea97119

Please sign in to comment.