mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-04-04 08:31:30 +00:00
Read bundled runtime version from build.txt in 'kotlinc' directory, not from plugin version
This commit is contained in:
@@ -50,4 +50,7 @@ public interface KotlinPaths {
|
||||
|
||||
@NotNull
|
||||
File getCompilerPath();
|
||||
|
||||
@NotNull
|
||||
File getBuildNumberFile();
|
||||
}
|
||||
|
||||
@@ -88,6 +88,12 @@ public class KotlinPathsFromHomeDir implements KotlinPaths {
|
||||
return getLibraryFile(PathUtil.KOTLIN_COMPILER_JAR);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public File getBuildNumberFile() {
|
||||
return new File(homePath, "build.txt");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private File getLibraryFile(@NotNull String fileName) {
|
||||
return new File(getLibPath(), fileName);
|
||||
|
||||
@@ -35,7 +35,6 @@ import com.intellij.util.ui.AsyncProcessIcon;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.idea.KotlinPluginUtil;
|
||||
import org.jetbrains.kotlin.idea.configuration.ConfigureKotlinInProjectUtilsKt;
|
||||
import org.jetbrains.kotlin.idea.configuration.KotlinProjectConfigurator;
|
||||
import org.jetbrains.kotlin.idea.versions.KotlinRuntimeLibraryUtilKt;
|
||||
@@ -172,7 +171,7 @@ public class ConfigureDialogWithModulesAndVersion extends DialogWrapper {
|
||||
protected static Collection<String> loadVersions() throws Exception {
|
||||
List<String> versions = Lists.newArrayList();
|
||||
|
||||
String bundledRuntimeVersion = KotlinRuntimeLibraryUtilKt.bundledRuntimeVersion(KotlinPluginUtil.getPluginVersion());
|
||||
String bundledRuntimeVersion = KotlinRuntimeLibraryUtilKt.bundledRuntimeVersion();
|
||||
if (ConfigureKotlinInProjectUtilsKt.isEap(bundledRuntimeVersion)) {
|
||||
HttpURLConnection eapConnection = HttpConfigurable.getInstance().openHttpConnection(EAP_VERSIONS_URL + bundledRuntimeVersion);
|
||||
try {
|
||||
|
||||
@@ -168,8 +168,18 @@ private enum class LibraryJarDescriptor private constructor(val jarName: String,
|
||||
JS_STDLIB_SRC_JAR(PathUtil.JS_LIB_SRC_JAR_NAME, false)
|
||||
}
|
||||
|
||||
fun bundledRuntimeVersion(): String {
|
||||
return bundledRuntimeBuildNumber ?: pluginRuntimeVersion(KotlinPluginUtil.getPluginVersion())
|
||||
}
|
||||
|
||||
private val bundledRuntimeBuildNumber: String? by lazy {
|
||||
val file = PathUtil.getKotlinPathsForIdeaPlugin().buildNumberFile
|
||||
if (file.exists()) file.readText().trim() else null
|
||||
}
|
||||
|
||||
private val PLUGIN_VERSIONS_SEPARATORS = arrayOf("Idea", "IJ", "release", "dev", "Studio")
|
||||
@JvmOverloads fun bundledRuntimeVersion(pluginVersion: String = KotlinPluginUtil.getPluginVersion()): String {
|
||||
|
||||
fun pluginRuntimeVersion(pluginVersion: String): String {
|
||||
var placeToSplit = -1
|
||||
|
||||
for (separator in PLUGIN_VERSIONS_SEPARATORS) {
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
package org.jetbrains.kotlin.idea
|
||||
|
||||
import junit.framework.TestCase
|
||||
import org.jetbrains.kotlin.idea.versions.bundledRuntimeVersion
|
||||
import org.jetbrains.kotlin.idea.versions.isRuntimeOutdated
|
||||
import org.jetbrains.kotlin.idea.versions.pluginRuntimeVersion
|
||||
import org.junit.Assert
|
||||
|
||||
|
||||
@@ -96,15 +96,15 @@ class KotlinRuntimeLibraryUtilTest : TestCase() {
|
||||
|
||||
private fun outdated(plugin: String, library: String) {
|
||||
Assert.assertTrue("Should be outdated: plugin=$plugin, library=$library",
|
||||
isRuntimeOutdated(library, bundledRuntimeVersion(plugin)))
|
||||
isRuntimeOutdated(library, pluginRuntimeVersion(plugin)))
|
||||
}
|
||||
|
||||
private fun notOutdated(plugin: String, library: String) {
|
||||
Assert.assertFalse("Should NOT be outdated: plugin=$plugin, library=$library",
|
||||
isRuntimeOutdated(library, bundledRuntimeVersion(plugin)))
|
||||
isRuntimeOutdated(library, pluginRuntimeVersion(plugin)))
|
||||
}
|
||||
|
||||
private fun test(version: String, expected: String) {
|
||||
Assert.assertEquals(expected, bundledRuntimeVersion(version))
|
||||
Assert.assertEquals(expected, pluginRuntimeVersion(version))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user