Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFred Bricon2018-02-23 16:03:43 -0500
committerFred Bricon2018-02-23 18:01:41 -0500
commit16e36aee8186939d9e9891e47dbe46ff135b47d6 (patch)
tree7708569c5dca9ed2410a4f7a5db7f9e6dcced2ff /org.eclipse.m2e.jdt
parentc4e4eba221dfa249d267af714fdc3b440edd9196 (diff)
downloadm2e-core-16e36aee8186939d9e9891e47dbe46ff135b47d6.tar.gz
m2e-core-16e36aee8186939d9e9891e47dbe46ff135b47d6.tar.xz
m2e-core-16e36aee8186939d9e9891e47dbe46ff135b47d6.zip
Bug 531476: add initial support for Java 10
Support JavaSE-10 only when it's available Change-Id: I9e5bb5499e000b512717e673bf0b2e5eee4d5a9d Signed-off-by: Fred Bricon <fbricon@gmail.com>
Diffstat (limited to 'org.eclipse.m2e.jdt')
-rw-r--r--org.eclipse.m2e.jdt/src/org/eclipse/m2e/jdt/internal/AbstractJavaProjectConfigurator.java27
-rw-r--r--org.eclipse.m2e.jdt/src/org/eclipse/m2e/jdt/internal/JavaProjectConversionParticipant.java12
2 files changed, 33 insertions, 6 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 8092a7e5..1c1b2367 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
@@ -14,6 +14,7 @@ package org.eclipse.m2e.jdt.internal;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
@@ -78,12 +79,11 @@ public abstract class AbstractJavaProjectConfigurator extends AbstractProjectCon
public static final String COMPILER_PLUGIN_GROUP_ID = "org.apache.maven.plugins";
- protected static final List<String> RELEASES = Arrays.asList("6,7,8,9".split(",")); //$NON-NLS-1$ //$NON-NLS-2$
+ protected static final List<String> RELEASES;
- protected static final List<String> SOURCES = Arrays.asList("1.1,1.2,1.3,1.4,1.5,5,1.6,6,1.7,7,1.8,8,9".split(",")); //$NON-NLS-1$ //$NON-NLS-2$
+ protected static final List<String> SOURCES;
- protected static final List<String> TARGETS = Arrays
- .asList("1.1,1.2,1.3,1.4,jsr14,1.5,5,1.6,6,1.7,7,1.8,8,9".split(",")); //$NON-NLS-1$ //$NON-NLS-2$
+ protected static final List<String> TARGETS;
private static final String GOAL_RESOURCES = "resources";
@@ -96,6 +96,13 @@ public abstract class AbstractJavaProjectConfigurator extends AbstractProjectCon
protected static final LinkedHashMap<String, String> ENVIRONMENTS = new LinkedHashMap<String, String>();
static {
+
+ List<String> sources = new ArrayList<>(Arrays.asList("1.1,1.2,1.3,1.4,1.5,5,1.6,6,1.7,7,1.8,8,9".split(","))); //$NON-NLS-1$ //$NON-NLS-2$
+
+ List<String> targets = new ArrayList<>(Arrays.asList("1.1,1.2,1.3,1.4,jsr14,1.5,5,1.6,6,1.7,7,1.8,8,9".split(","))); //$NON-NLS-1$ //$NON-NLS-2$
+
+ List<String> releases = new ArrayList<>(Arrays.asList("6,7,8,9".split(","))); //$NON-NLS-1$ //$NON-NLS-2$
+
ENVIRONMENTS.put("1.1", "JRE-1.1"); //$NON-NLS-1$ //$NON-NLS-2$
ENVIRONMENTS.put("1.2", "J2SE-1.2"); //$NON-NLS-1$ //$NON-NLS-2$
ENVIRONMENTS.put("1.3", "J2SE-1.3"); //$NON-NLS-1$ //$NON-NLS-2$
@@ -106,6 +113,18 @@ public abstract class AbstractJavaProjectConfigurator extends AbstractProjectCon
ENVIRONMENTS.put("1.7", "JavaSE-1.7"); //$NON-NLS-1$ //$NON-NLS-2$
ENVIRONMENTS.put("1.8", "JavaSE-1.8"); //$NON-NLS-1$ //$NON-NLS-2$
ENVIRONMENTS.put("9", "JavaSE-9"); //$NON-NLS-1$ //$NON-NLS-2$
+
+ IExecutionEnvironment javaSe10 = JavaRuntime.getExecutionEnvironmentsManager().getEnvironment("JavaSE-10");//$NON-NLS-1$
+ if(javaSe10 != null) {
+ String level = "10";//$NON-NLS-1$
+ sources.add(level);
+ targets.add(level);
+ releases.add(level);
+ ENVIRONMENTS.put(level, javaSe10.getId());
+ }
+ SOURCES = Collections.unmodifiableList(sources);
+ TARGETS = Collections.unmodifiableList(targets);
+ RELEASES = Collections.unmodifiableList(releases);
}
protected static final String DEFAULT_COMPILER_LEVEL = "1.5"; //$NON-NLS-1$
diff --git a/org.eclipse.m2e.jdt/src/org/eclipse/m2e/jdt/internal/JavaProjectConversionParticipant.java b/org.eclipse.m2e.jdt/src/org/eclipse/m2e/jdt/internal/JavaProjectConversionParticipant.java
index 53398299..68f96e53 100644
--- a/org.eclipse.m2e.jdt/src/org/eclipse/m2e/jdt/internal/JavaProjectConversionParticipant.java
+++ b/org.eclipse.m2e.jdt/src/org/eclipse/m2e/jdt/internal/JavaProjectConversionParticipant.java
@@ -92,7 +92,7 @@ public class JavaProjectConversionParticipant extends AbstractProjectConversionP
private static final String CONFIGURATION_KEY = "configuration"; //$NON-NLS-1$
- private static final String VERSION_9 = "9";//to be replaced by JavaCore.VERSION_9
+ private static final float VERSION_9 = 9.0f;
public boolean accept(IProject project) throws CoreException {
boolean accepts = project != null && project.isAccessible() && project.hasNature(JavaCore.NATURE_ID);
@@ -195,7 +195,15 @@ public class JavaProjectConversionParticipant extends AbstractProjectConversionP
private boolean canUseReleaseProperty(String source, String target) {
//source and target are guaranteed to be not null at this point
- return source.equals(target) && source.compareTo(VERSION_9) >= 0;
+ return source.equals(target) && asFloat(source) >= VERSION_9;
+ }
+
+ private float asFloat(String source) {
+ try {
+ return Float.parseFloat(source);
+ } catch(Exception ignored) {
+ }
+ return 0f;
}
private Plugin getOrCreateCompilerPlugin(Build build) {

Back to the top