aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIgor Fedorenko2012-08-03 07:01:10 -0400
committerIgor Fedorenko2012-08-03 07:11:23 -0400
commite7289312212ba62e522c1fa40604c25a7c327378 (patch)
tree77b6f724d0ab1c4ebe07c301e4c814772c914d7a
parentdf2c3591ae0e641a8d12c13ca9c1058eaf8439b2 (diff)
downloadorg.eclipse.tycho-e7289312212ba62e522c1fa40604c25a7c327378.tar.gz
org.eclipse.tycho-e7289312212ba62e522c1fa40604c25a7c327378.tar.xz
org.eclipse.tycho-e7289312212ba62e522c1fa40604c25a7c327378.zip
386278 added support for java target version aliases
Change-Id: I6ed8b5523cacd0104f818dad449a55c19c74452e Signed-off-by: Igor Fedorenko <igor@ifedorenko.com>
-rw-r--r--tycho-core/src/main/java/org/eclipse/tycho/core/utils/ExecutionEnvironment.java36
-rw-r--r--tycho-core/src/test/java/org/eclipse/tycho/core/test/ExecutionEnvironmentTest.java8
2 files changed, 36 insertions, 8 deletions
diff --git a/tycho-core/src/main/java/org/eclipse/tycho/core/utils/ExecutionEnvironment.java b/tycho-core/src/main/java/org/eclipse/tycho/core/utils/ExecutionEnvironment.java
index a6ce3116..6b8e3bef 100644
--- a/tycho-core/src/main/java/org/eclipse/tycho/core/utils/ExecutionEnvironment.java
+++ b/tycho-core/src/main/java/org/eclipse/tycho/core/utils/ExecutionEnvironment.java
@@ -12,7 +12,9 @@ package org.eclipse.tycho.core.utils;
import java.util.ArrayList;
import java.util.Collections;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import java.util.Properties;
import org.eclipse.osgi.util.ManifestElement;
@@ -29,6 +31,22 @@ import org.osgi.framework.Version;
*/
public class ExecutionEnvironment implements Comparable<ExecutionEnvironment> {
+ private static final Map<String, String> TARGET_ALIASES;
+
+ static {
+ // http://help.eclipse.org/juno/topic/org.eclipse.jdt.doc.user/tasks/task-using_batch_compiler.htm
+
+ Map<String, String> targetAliases = new HashMap<String, String>();
+ targetAliases.put("jsr14", "1.4");
+ targetAliases.put("5", "1.5");
+ targetAliases.put("5.0", "1.5");
+ targetAliases.put("6", "1.6");
+ targetAliases.put("6.0", "1.6");
+ targetAliases.put("7", "1.7");
+ targetAliases.put("7.0", "1.7");
+ TARGET_ALIASES = Collections.unmodifiableMap(targetAliases);
+ }
+
private String profileName;
private String compilerSourceLevel;
private String compilerTargetLevel;
@@ -124,18 +142,20 @@ public class ExecutionEnvironment implements Comparable<ExecutionEnvironment> {
}
try {
- Version thisTargetVersion = Version.parseVersion(compilerTargetLevel);
-
- if ("jsr14".equalsIgnoreCase(target)) {
- target = "1.4";
- }
-
- Version targetVersion = Version.parseVersion(target);
-
+ Version thisTargetVersion = toTargetVersion(compilerTargetLevel);
+ Version targetVersion = toTargetVersion(target);
return thisTargetVersion.compareTo(targetVersion) >= 0;
} catch (IllegalArgumentException e) {
// we could not parse one or both of the provided target level, assume they are incompatible
return false;
}
}
+
+ private static Version toTargetVersion(String target) {
+ String targetAlias = TARGET_ALIASES.get(target.trim().toLowerCase());
+ if (targetAlias != null) {
+ target = targetAlias;
+ }
+ return Version.parseVersion(target);
+ }
}
diff --git a/tycho-core/src/test/java/org/eclipse/tycho/core/test/ExecutionEnvironmentTest.java b/tycho-core/src/test/java/org/eclipse/tycho/core/test/ExecutionEnvironmentTest.java
index f407e12e..cc4de0e9 100644
--- a/tycho-core/src/test/java/org/eclipse/tycho/core/test/ExecutionEnvironmentTest.java
+++ b/tycho-core/src/test/java/org/eclipse/tycho/core/test/ExecutionEnvironmentTest.java
@@ -127,6 +127,14 @@ public class ExecutionEnvironmentTest {
assertTrue(j2SE14Environment.isCompatibleCompilerTargetLevel("1.1"));
assertTrue(j2SE14Environment.isCompatibleCompilerTargetLevel("1.2"));
assertFalse(j2SE14Environment.isCompatibleCompilerTargetLevel("1.3"));
+
+ // version aliases
+ assertTrue(j2SE5Enviroment.isCompatibleCompilerTargetLevel("5"));
+ assertTrue(j2SE5Enviroment.isCompatibleCompilerTargetLevel("5.0"));
+ assertTrue(javaSE6Enviroment.isCompatibleCompilerTargetLevel("6"));
+ assertTrue(javaSE6Enviroment.isCompatibleCompilerTargetLevel("6.0"));
+ assertTrue(javaSE7Enviroment.isCompatibleCompilerTargetLevel("7"));
+ assertTrue(javaSE7Enviroment.isCompatibleCompilerTargetLevel("7.0"));
}
@Test