Don't show pre-1.1.0 version of Kotlin in version chooser when configuring JS projects
#KT-16400 Fixed
This commit is contained in:
+2
@@ -44,6 +44,8 @@ class KotlinJavascriptMavenConfigurator : KotlinMavenConfigurator(null, false, K
|
||||
override val targetPlatform: TargetPlatform
|
||||
get() = JsPlatform
|
||||
|
||||
override fun getMinimumSupportedVersion() = "1.1.0"
|
||||
|
||||
companion object {
|
||||
private val NAME = "js maven"
|
||||
private val PRESENTABLE_TEXT = "JavaScript Maven"
|
||||
|
||||
+3
-1
@@ -97,7 +97,7 @@ abstract class KotlinMavenConfigurator
|
||||
}
|
||||
|
||||
override fun configure(project: Project, excludeModules: Collection<Module>) {
|
||||
val dialog = ConfigureDialogWithModulesAndVersion(project, this, excludeModules)
|
||||
val dialog = ConfigureDialogWithModulesAndVersion(project, this, excludeModules, getMinimumSupportedVersion())
|
||||
|
||||
dialog.show()
|
||||
if (!dialog.isOK) return
|
||||
@@ -118,6 +118,8 @@ abstract class KotlinMavenConfigurator
|
||||
}
|
||||
}
|
||||
|
||||
protected open fun getMinimumSupportedVersion() = "1.0.0"
|
||||
|
||||
protected abstract fun isKotlinModule(module: Module): Boolean
|
||||
protected abstract fun isRelevantGoal(goalName: String): Boolean
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ class KotlinJsGradleModuleConfigurator : KotlinWithGradleConfigurator() {
|
||||
override val targetPlatform: TargetPlatform = JsPlatform
|
||||
|
||||
override val applyPluginDirective: String = APPLY_KOTLIN_JS
|
||||
override fun getMinimumSupportedVersion() = "1.1.0"
|
||||
|
||||
override fun getDependencyDirective(sdk: Sdk?, version: String): String {
|
||||
return KotlinWithGradleConfigurator.getDependencySnippet(MAVEN_JS_STDLIB_ID)
|
||||
|
||||
@@ -76,6 +76,8 @@ abstract class KotlinWithGradleConfigurator : KotlinProjectConfigurator {
|
||||
return KotlinPluginUtil.isGradleModule(module) && !KotlinPluginUtil.isAndroidGradleModule(module)
|
||||
}
|
||||
|
||||
protected open fun getMinimumSupportedVersion() = "1.0.0"
|
||||
|
||||
private fun isFileConfigured(projectGradleFile: GroovyFile): Boolean {
|
||||
val fileText = projectGradleFile.text
|
||||
return containsDirective(fileText, applyPluginDirective) &&
|
||||
@@ -85,7 +87,7 @@ abstract class KotlinWithGradleConfigurator : KotlinProjectConfigurator {
|
||||
|
||||
@JvmSuppressWildcards
|
||||
override fun configure(project: Project, excludeModules: Collection<Module>) {
|
||||
val dialog = ConfigureDialogWithModulesAndVersion(project, this, excludeModules)
|
||||
val dialog = ConfigureDialogWithModulesAndVersion(project, this, excludeModules, getMinimumSupportedVersion())
|
||||
|
||||
dialog.show()
|
||||
if (!dialog.isOK) return
|
||||
|
||||
+7
-4
@@ -57,6 +57,7 @@ public class ConfigureDialogWithModulesAndVersion extends DialogWrapper {
|
||||
|
||||
private static final String EAP_VERSIONS_URL =
|
||||
"https://bintray.com/kotlin/kotlin-eap/kotlin/";
|
||||
@NotNull private final String minimumVersion;
|
||||
|
||||
private final ChooseModulePanel chooseModulePanel;
|
||||
|
||||
@@ -70,12 +71,14 @@ public class ConfigureDialogWithModulesAndVersion extends DialogWrapper {
|
||||
public ConfigureDialogWithModulesAndVersion(
|
||||
@NotNull Project project,
|
||||
@NotNull KotlinProjectConfigurator configurator,
|
||||
@NotNull Collection<Module> excludeModules
|
||||
@NotNull Collection<Module> excludeModules,
|
||||
@NotNull String minimumVersion
|
||||
) {
|
||||
super(project);
|
||||
|
||||
setTitle("Configure Kotlin in Project");
|
||||
|
||||
this.minimumVersion = minimumVersion;
|
||||
init();
|
||||
|
||||
ProgressManager.getInstance().run(new Task.Backgroundable(project, "Find Kotlin Maven plugin versions", false) {
|
||||
@@ -121,7 +124,7 @@ public class ConfigureDialogWithModulesAndVersion extends DialogWrapper {
|
||||
private void loadKotlinVersions() {
|
||||
Collection<String> items;
|
||||
try {
|
||||
items = loadVersions();
|
||||
items = loadVersions(minimumVersion);
|
||||
hideLoader();
|
||||
}
|
||||
catch (Throwable t) {
|
||||
@@ -169,7 +172,7 @@ public class ConfigureDialogWithModulesAndVersion extends DialogWrapper {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected static Collection<String> loadVersions() throws Exception {
|
||||
protected static Collection<String> loadVersions(String minimumVersion) throws Exception {
|
||||
List<String> versions = Lists.newArrayList();
|
||||
|
||||
String bundledRuntimeVersion = KotlinRuntimeLibraryUtilKt.bundledRuntimeVersion();
|
||||
@@ -204,7 +207,7 @@ public class ConfigureDialogWithModulesAndVersion extends DialogWrapper {
|
||||
|
||||
for (JsonElement element : docsElements) {
|
||||
String versionNumber = element.getAsJsonObject().get("v").getAsString();
|
||||
if (VersionComparatorUtil.compare("1.0.0", versionNumber) <= 0) {
|
||||
if (VersionComparatorUtil.compare(minimumVersion, versionNumber) <= 0) {
|
||||
versions.add(versionNumber);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,10 +17,7 @@
|
||||
package org.jetbrains.kotlin.idea.configuration;
|
||||
|
||||
import com.intellij.framework.library.LibraryVersionProperties;
|
||||
import com.intellij.openapi.application.PathMacros;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.libraries.Library;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import org.jetbrains.kotlin.cli.common.arguments.K2JSCompilerArguments;
|
||||
@@ -30,7 +27,6 @@ import org.jetbrains.kotlin.idea.framework.JSLibraryStdPresentationProvider;
|
||||
import org.jetbrains.kotlin.idea.framework.KotlinLibraryUtilKt;
|
||||
import org.jetbrains.kotlin.idea.project.PlatformKt;
|
||||
import org.jetbrains.kotlin.idea.versions.KotlinRuntimeLibraryUtilKt;
|
||||
import org.jetbrains.kotlin.utils.PathUtil;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -174,15 +170,6 @@ public class ConfigureKotlinTest extends AbstractConfigureKotlinTest {
|
||||
assertEquals("1.0.6", properties.getVersionString());
|
||||
}
|
||||
|
||||
private void doTestConfigureModulesWithNonDefaultSetup(KotlinWithLibraryConfigurator configurator) {
|
||||
assertNoFilesInDefaultPaths();
|
||||
|
||||
Module[] modules = getModules();
|
||||
for (Module module : modules) {
|
||||
assertNotConfigured(module, configurator);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
public void testJvmProjectWithV1FacetConfig() {
|
||||
KotlinFacetSettings settings = KotlinFacetSettingsProvider.Companion.getInstance(myProject).getSettings(getModule());
|
||||
|
||||
@@ -17,12 +17,16 @@
|
||||
package org.jetbrains.kotlin.idea.framework.ui;
|
||||
|
||||
import com.intellij.testFramework.LightIdeaTestCase;
|
||||
import com.intellij.util.text.VersionComparatorUtil;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public class LoadVersionsFromMavenTest extends LightIdeaTestCase {
|
||||
public void testDownload() throws Exception {
|
||||
Collection<String> versions = ConfigureDialogWithModulesAndVersion.loadVersions();
|
||||
assert versions.size() > 0;
|
||||
Collection<String> versions = ConfigureDialogWithModulesAndVersion.loadVersions("1.0.0");
|
||||
assertTrue(versions.size() > 0);
|
||||
for (String version : versions) {
|
||||
assertTrue(VersionComparatorUtil.compare(version, "1.0.0") >= 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user