Reorganize dependencies around kotlin-compiler.jar
#KT-26807 Fixed
This commit is contained in:
@@ -20,6 +20,7 @@ dependencies {
|
||||
compilerClasspath(project(":kotlin-reflect"))
|
||||
compilerClasspath(project(":kotlin-stdlib"))
|
||||
compilerClasspath(project(":kotlin-script-runtime"))
|
||||
compilerClasspath(commonDep("org.jetbrains.intellij.deps", "trove4j"))
|
||||
compileOnly(project(":compiler:cli-common")) // TODO: fix import (workaround for jps build)
|
||||
testCompileOnly(project(":core:util.runtime")) // TODO: fix import (workaround for jps build)
|
||||
testCompileOnly(project(":compiler:daemon-common")) // TODO: fix import (workaround for jps build)
|
||||
|
||||
@@ -16,9 +16,12 @@ import kotlin.script.templates.standard.ScriptTemplateWithArgs
|
||||
|
||||
// TODO: consider moving all these utilites to the build-common or some other shared compiler API module
|
||||
|
||||
// Kotlin Compiler dependencies
|
||||
internal const val KOTLIN_JAVA_STDLIB_JAR = "kotlin-stdlib.jar"
|
||||
internal const val KOTLIN_JAVA_REFLECT_JAR = "kotlin-reflect.jar"
|
||||
internal const val KOTLIN_JAVA_SCRIPT_RUNTIME_JAR = "kotlin-script-runtime.jar"
|
||||
internal const val TROVE4J_JAR = "trove4j.jar"
|
||||
|
||||
internal const val KOTLIN_COMPILER_NAME = "kotlin-compiler"
|
||||
internal const val KOTLIN_COMPILER_JAR = "$KOTLIN_COMPILER_NAME.jar"
|
||||
|
||||
@@ -160,7 +163,8 @@ object KotlinJars {
|
||||
val kotlinLibsJars = listOf(
|
||||
KOTLIN_JAVA_STDLIB_JAR,
|
||||
KOTLIN_JAVA_REFLECT_JAR,
|
||||
KOTLIN_JAVA_SCRIPT_RUNTIME_JAR
|
||||
KOTLIN_JAVA_SCRIPT_RUNTIME_JAR,
|
||||
TROVE4J_JAR
|
||||
)
|
||||
val kotlinBaseJars = kotlinCompilerJars + kotlinLibsJars
|
||||
|
||||
|
||||
+23
-4
@@ -38,6 +38,7 @@ private val KOTLIN_SCRIPT_RUNTIME_EXPECTED_CLASS = "kotlin.script.templates.Anno
|
||||
private val KOTLIN_SCRIPT_ANNOTATION_EXPECTED_CLASS = "kotlin.script.experimental.annotations.KotlinScript"
|
||||
private val KOTLIN_JVM_SCRIPT_COMPILER_EXPECTED_CLASS = "kotlin.script.experimental.jvm.JvmScriptCompiler"
|
||||
private val KOTLIN_REFLECT_EXPECTED_CLASS = "kotlin.reflect.full.KClasses"
|
||||
private val TROVE4J_EXPECTED_CLASS = "gnu.trove.THashMap"
|
||||
internal const val KOTLIN_MODULE_GROUP = "org.jetbrains.kotlin"
|
||||
private val KOTLIN_GRADLE_PLUGIN = "kotlin-gradle-plugin"
|
||||
internal const val KOTLIN_COMPILER_EMBEDDABLE = "kotlin-compiler-embeddable"
|
||||
@@ -50,27 +51,45 @@ private val KOTLIN_REFLECT = "kotlin-reflect"
|
||||
internal fun findKotlinJvmCompilerClasspath(project: Project): List<File> =
|
||||
findKotlinModuleJar(project, K2JVM_COMPILER_CLASS, KOTLIN_COMPILER_EMBEDDABLE).let {
|
||||
if (it.isEmpty()) it
|
||||
else it + findKotlinStdlibClasspath(project) + findKotlinScriptRuntimeClasspath(project) + findKotlinReflectClasspath(project)
|
||||
else it + findKotlinCompilerClasspath(project)
|
||||
}
|
||||
|
||||
internal fun findKotlinJsCompilerClasspath(project: Project): List<File> =
|
||||
findKotlinModuleJar(project, K2JS_COMPILER_CLASS, KOTLIN_COMPILER_EMBEDDABLE).let {
|
||||
if (it.isEmpty()) it
|
||||
else it + findKotlinStdlibClasspath(project) + findKotlinScriptRuntimeClasspath(project) + findKotlinReflectClasspath(project)
|
||||
else it + findKotlinCompilerClasspath(project)
|
||||
}
|
||||
|
||||
internal fun findKotlinMetadataCompilerClasspath(project: Project): List<File> =
|
||||
findKotlinModuleJar(project, K2METADATA_COMPILER_CLASS, KOTLIN_COMPILER_EMBEDDABLE).let {
|
||||
if (it.isEmpty()) it
|
||||
else it + findKotlinStdlibClasspath(project) + findKotlinScriptRuntimeClasspath(project) + findKotlinReflectClasspath(project)
|
||||
else it + findKotlinCompilerClasspath(project)
|
||||
}
|
||||
|
||||
internal fun findKotlinJsDceClasspath(project: Project): List<File> =
|
||||
findKotlinModuleJar(project, K2JS_DCE_CLASS, KOTLIN_COMPILER_EMBEDDABLE).let {
|
||||
if (it.isEmpty()) it
|
||||
else it + findKotlinStdlibClasspath(project) + findKotlinScriptRuntimeClasspath(project) + findKotlinReflectClasspath(project)
|
||||
else it + findKotlinCompilerClasspath(project)
|
||||
}
|
||||
|
||||
internal fun findKotlinCompilerClasspath(project: Project): List<File> {
|
||||
return findKotlinStdlibClasspath(project) +
|
||||
findKotlinScriptRuntimeClasspath(project) +
|
||||
findKotlinReflectClasspath(project) +
|
||||
listOfNotNull(findTrove4j())
|
||||
}
|
||||
|
||||
internal fun findTrove4j(): File? {
|
||||
val classLoader = Thread.currentThread().contextClassLoader
|
||||
val classFromTrove4j = try {
|
||||
classLoader.loadClass(TROVE4J_EXPECTED_CLASS)
|
||||
} catch (e: ClassNotFoundException) {
|
||||
null
|
||||
} ?: return null
|
||||
|
||||
return findJarByClass(classFromTrove4j)
|
||||
}
|
||||
|
||||
internal fun findKotlinStdlibClasspath(project: Project): List<File> =
|
||||
findKotlinModuleJar(project, KOTLIN_STDLIB_EXPECTED_CLASS, KOTLIN_STDLIB)
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ dependencies {
|
||||
compile(project(":kotlin-stdlib"))
|
||||
compile(project(":kotlin-script-runtime"))
|
||||
compile(project(":kotlin-scripting-jvm"))
|
||||
compile(commonDep("org.jetbrains.intellij.deps", "trove4j"))
|
||||
compileOnly(project(":compiler:cli"))
|
||||
compileOnly(project(":compiler:daemon-common"))
|
||||
compile(projectRuntimeJar(":kotlin-daemon-client"))
|
||||
|
||||
Reference in New Issue
Block a user