mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Don't give any preference to LTS JDK versions because LTS is not really a thing (IDEA-CR-31972)
This commit is contained in:
+2
-11
@@ -5,10 +5,8 @@ import com.intellij.ide.util.PropertiesComponent;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.components.BaseComponent;
|
||||
import com.intellij.openapi.projectRoots.JavaSdk;
|
||||
import com.intellij.openapi.projectRoots.JavaSdkVersion;
|
||||
import com.intellij.openapi.projectRoots.ProjectJdkTable;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
@@ -31,23 +29,16 @@ public class DefaultJdkConfigurator implements BaseComponent {
|
||||
if (jdks.isEmpty()) {
|
||||
Collection<String> homePaths = myJavaSdk.suggestHomePaths();
|
||||
if (homePaths.isEmpty()) return;
|
||||
String homePath = ContainerUtil.find(homePaths, path -> isLTS(path));
|
||||
if (homePath == null) homePath = homePaths.iterator().next();
|
||||
String homePath = homePaths.iterator().next();
|
||||
if (homePath != null && myJavaSdk.isValidSdkHome(homePath)) {
|
||||
String suggestedName = myJavaSdk.suggestSdkName(null, homePath);
|
||||
if (suggestedName != null) {
|
||||
String finalHomePath = homePath;
|
||||
ApplicationManager.getApplication().runWriteAction(() ->
|
||||
myProjectJdkTable.addJdk(myJavaSdk.createJdk(suggestedName, finalHomePath, false))
|
||||
myProjectJdkTable.addJdk(myJavaSdk.createJdk(suggestedName, homePath, false))
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
myPropertiesComponent.setValue("defaultJdkConfigured", true);
|
||||
}
|
||||
|
||||
private static boolean isLTS(String path) {
|
||||
JavaSdkVersion version = JavaSdkVersion.fromVersionString(path);
|
||||
return version != null && version.isLongTermSupport();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,25 +15,23 @@ import java.util.Arrays;
|
||||
* @see LanguageLevel
|
||||
*/
|
||||
public enum JavaSdkVersion {
|
||||
JDK_1_0(LanguageLevel.JDK_1_3, false),
|
||||
JDK_1_1(LanguageLevel.JDK_1_3, false),
|
||||
JDK_1_2(LanguageLevel.JDK_1_3, false),
|
||||
JDK_1_3(LanguageLevel.JDK_1_3, false),
|
||||
JDK_1_4(LanguageLevel.JDK_1_4, false),
|
||||
JDK_1_5(LanguageLevel.JDK_1_5, false),
|
||||
JDK_1_6(LanguageLevel.JDK_1_6, false),
|
||||
JDK_1_7(LanguageLevel.JDK_1_7, false),
|
||||
JDK_1_8(LanguageLevel.JDK_1_8, true),
|
||||
JDK_1_9(LanguageLevel.JDK_1_9, false),
|
||||
JDK_10(LanguageLevel.JDK_10, false),
|
||||
JDK_11(LanguageLevel.JDK_11, true);
|
||||
JDK_1_0(LanguageLevel.JDK_1_3),
|
||||
JDK_1_1(LanguageLevel.JDK_1_3),
|
||||
JDK_1_2(LanguageLevel.JDK_1_3),
|
||||
JDK_1_3(LanguageLevel.JDK_1_3),
|
||||
JDK_1_4(LanguageLevel.JDK_1_4),
|
||||
JDK_1_5(LanguageLevel.JDK_1_5),
|
||||
JDK_1_6(LanguageLevel.JDK_1_6),
|
||||
JDK_1_7(LanguageLevel.JDK_1_7),
|
||||
JDK_1_8(LanguageLevel.JDK_1_8),
|
||||
JDK_1_9(LanguageLevel.JDK_1_9),
|
||||
JDK_10(LanguageLevel.JDK_10),
|
||||
JDK_11(LanguageLevel.JDK_11);
|
||||
|
||||
private final LanguageLevel myMaxLanguageLevel;
|
||||
private final boolean myLongTermSupport;
|
||||
|
||||
JavaSdkVersion(LanguageLevel maxLanguageLevel, boolean longTermSupport) {
|
||||
JavaSdkVersion(LanguageLevel maxLanguageLevel) {
|
||||
myMaxLanguageLevel = maxLanguageLevel;
|
||||
myLongTermSupport = longTermSupport;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -41,10 +39,6 @@ public enum JavaSdkVersion {
|
||||
return myMaxLanguageLevel;
|
||||
}
|
||||
|
||||
public boolean isLongTermSupport() {
|
||||
return myLongTermSupport;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getDescription() {
|
||||
int feature = ordinal();
|
||||
|
||||
Reference in New Issue
Block a user