diff --git a/jps/jps-builders/src/org/jetbrains/jps/incremental/java/JavaBuilder.java b/jps/jps-builders/src/org/jetbrains/jps/incremental/java/JavaBuilder.java index 139bbf20ef0e..71babde60c79 100644 --- a/jps/jps-builders/src/org/jetbrains/jps/incremental/java/JavaBuilder.java +++ b/jps/jps-builders/src/org/jetbrains/jps/incremental/java/JavaBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -749,18 +749,7 @@ public class JavaBuilder extends ModuleLevelBuilder { private static String getLanguageLevel(JpsModule module) { final LanguageLevel level = JpsJavaExtensionService.getInstance().getLanguageLevel(module); - if (level != null) { - switch (level) { - case JDK_1_3: return "1.3"; - case JDK_1_4: return "1.4"; - case JDK_1_5: return "1.5"; - case JDK_1_6: return "1.6"; - case JDK_1_7: return "1.7"; - case JDK_1_8: return "8"; - case JDK_1_9: return "9"; - } - } - return null; + return level != null ? level.getComplianceOption() : null; } private static boolean isEncodingSet(List options) { diff --git a/jps/model-api/src/org/jetbrains/jps/model/java/LanguageLevel.java b/jps/model-api/src/org/jetbrains/jps/model/java/LanguageLevel.java index 3d9b302d38cf..c18991800f96 100644 --- a/jps/model-api/src/org/jetbrains/jps/model/java/LanguageLevel.java +++ b/jps/model-api/src/org/jetbrains/jps/model/java/LanguageLevel.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,9 +15,26 @@ */ package org.jetbrains.jps.model.java; +import org.jetbrains.annotations.NotNull; + /** * @author nik */ public enum LanguageLevel { - JDK_1_3, JDK_1_4, JDK_1_5, JDK_1_6, JDK_1_7, JDK_1_8, JDK_1_9 + JDK_1_3("1.3"), JDK_1_4("1.4"), JDK_1_5("1.5"), JDK_1_6("1.6"), JDK_1_7("1.7"), JDK_1_8("1.8"), JDK_1_9("1.9"); + + private final String myComplianceOption; + + LanguageLevel(String complianceOption) { + myComplianceOption = complianceOption; + } + + /** + * String representation of the level, suitable to pass as a value of compiler's "-source" and "-target" options. + * Should work for Javac and ECJ (including ECJ-based) compilers. + */ + @NotNull + public String getComplianceOption() { + return myComplianceOption; + } }