From 76fc3b40d5adc06ad78e12b53e4f99209bb98abb Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Mon, 23 Jan 2017 11:30:53 +0300 Subject: [PATCH] Do not consider Kotlin compiler as library in runtime versions checker Otherwise because there's no Kotlin-Version in its manifest, it's regarded as a 1.0 runtime library which conflicts with 1.1 libraries --- .../kotlin/cli/jvm/JvmRuntimeVersionsConsistencyChecker.kt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/JvmRuntimeVersionsConsistencyChecker.kt b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/JvmRuntimeVersionsConsistencyChecker.kt index 61a6a95b485..b0b6efa6201 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/JvmRuntimeVersionsConsistencyChecker.kt +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/JvmRuntimeVersionsConsistencyChecker.kt @@ -16,6 +16,7 @@ package org.jetbrains.kotlin.cli.jvm +import com.intellij.ide.highlighter.JavaClassFileType import com.intellij.openapi.diagnostic.Logger import com.intellij.openapi.vfs.VfsUtilCore import com.intellij.openapi.vfs.VirtualFile @@ -55,6 +56,7 @@ object JvmRuntimeVersionsConsistencyChecker { private const val KOTLIN_STDLIB_MODULE = "$META_INF/kotlin-stdlib.kotlin_module" private const val KOTLIN_REFLECT_MODULE = "$META_INF/kotlin-reflection.kotlin_module" + private const val KOTLIN_COMPILER_MODULE = "$META_INF/kotlin-compiler.kotlin_module" private val KOTLIN_VERSION_ATTRIBUTE: String private val CURRENT_COMPILER_VERSION: MavenComparableVersion @@ -217,6 +219,11 @@ object JvmRuntimeVersionsConsistencyChecker { private fun getKotlinRuntimeComponent(jar: VirtualFile, manifest: Manifest): String? { manifest.mainAttributes.getValue(KOTLIN_RUNTIME_COMPONENT_ATTRIBUTE)?.let { return it } + // Do not treat kotlin-compiler and kotlin-compiler-embeddable as Kotlin runtime libraries. + // The second condition is needed because when the compiler is built with "compiler-quick", there's no kotlin-compiler.kotlin_module + if (jar.findFileByRelativePath(KOTLIN_COMPILER_MODULE) != null || + jar.findFileByRelativePath(this::class.java.name.replace('.', '/') + "." + JavaClassFileType.INSTANCE.defaultExtension) != null) return null + if (jar.findFileByRelativePath(KOTLIN_STDLIB_MODULE) != null) return KOTLIN_RUNTIME_COMPONENT_MAIN if (jar.findFileByRelativePath(KOTLIN_REFLECT_MODULE) != null) return KOTLIN_RUNTIME_COMPONENT_MAIN