Reorganize dependencies around kotlin-compiler.jar

#KT-26807 Fixed
This commit is contained in:
Mikhail Zarechenskiy
2018-12-12 11:51:25 +03:00
parent 30c769c19a
commit d5ebe2e66a
18 changed files with 98 additions and 31 deletions
+1 -1
View File
@@ -17,7 +17,7 @@ sourceSets {
}
runtimeJar {
manifest.attributes.put("Class-Path", "kotlin-stdlib.jar kotlin-reflect.jar kotlin-script-runtime.jar kotlin-preloader.jar")
manifest.attributes.put("Class-Path", "$compilerManifestClassPath kotlin-preloader.jar")
}
dist()
+1
View File
@@ -167,6 +167,7 @@ extra["versions.robolectric"] = "3.1"
extra["versions.org.springframework"] = "4.2.0.RELEASE"
extra["versions.jflex"] = "1.7.0"
extra["versions.markdown"] = "0.1.25"
extra["versions.trove4j"] = "1.0.20181211"
val isTeamcityBuild = project.hasProperty("teamcity") || System.getenv("TEAMCITY_VERSION") != null
val intellijUltimateEnabled = project.getBooleanProperty("intellijUltimateEnabled") ?: isTeamcityBuild
+3
View File
@@ -104,6 +104,9 @@ fun Project.firstFromJavaHomeThatExists(vararg paths: String, jdkHome: File = Fi
fun Project.toolsJar(jdkHome: File = File(this.property("JDK_18") as String)): File? =
firstFromJavaHomeThatExists("lib/tools.jar", jdkHome = jdkHome)
val compilerManifestClassPath
get() = "kotlin-stdlib.jar kotlin-reflect.jar kotlin-script-runtime.jar trove4j.jar"
object EmbeddedComponents {
val CONFIGURATION_NAME = "embeddedComponents"
}
-1
View File
@@ -18,7 +18,6 @@ val packagesToRelocate =
"org.jdom",
"org.picocontainer",
"org.jline",
"gnu",
"org.fusesource",
"kotlinx.coroutines")
@@ -19,6 +19,7 @@ package org.jetbrains.kotlin.utils;
import org.jetbrains.annotations.NotNull;
import java.io.File;
import java.util.List;
public interface KotlinPaths {
@NotNull
@@ -60,6 +61,12 @@ public interface KotlinPaths {
@NotNull
File getSamWithReceiverJarPath();
@NotNull
File getTrove4jJarPath();
@NotNull
List<File> getCompilerClasspath();
@NotNull
File getCompilerPath();
@@ -16,9 +16,11 @@
package org.jetbrains.kotlin.utils;
import kotlin.collections.CollectionsKt;
import org.jetbrains.annotations.NotNull;
import java.io.File;
import java.util.List;
public class KotlinPathsFromHomeDir implements KotlinPaths {
// kotlinc directory
@@ -106,6 +108,18 @@ public class KotlinPathsFromHomeDir implements KotlinPaths {
return getLibraryFile(PathUtil.SAM_WITH_RECEIVER_PLUGIN_JAR_NAME);
}
@NotNull
@Override
public File getTrove4jJarPath() {
return getLibraryFile(PathUtil.TROVE4J_NAME);
}
@NotNull
@Override
public List<File> getCompilerClasspath() {
return CollectionsKt.listOf(getStdlibPath(), getReflectPath(), getScriptRuntimePath(), getTrove4jJarPath());
}
@NotNull
@Override
public File getCompilerPath() {
@@ -71,6 +71,9 @@ object PathUtil {
const val KOTLIN_JAVA_STDLIB_SRC_JAR_OLD = "kotlin-runtime-sources.jar"
const val TROVE4J_NAME = "trove4j"
const val TROVE4J_JAR = "$TROVE4J_NAME.jar"
const val KOTLIN_COMPILER_NAME = "kotlin-compiler"
const val KOTLIN_COMPILER_JAR = "$KOTLIN_COMPILER_NAME.jar"
@@ -70,7 +70,8 @@ class KotlinConsoleKeeper(val project: Project) {
//paramList.add("-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005")
val kotlinPaths = PathUtil.kotlinPathsForIdeaPlugin
val replClassPath = listOf(kotlinPaths.compilerPath, kotlinPaths.reflectPath, kotlinPaths.stdlibPath, kotlinPaths.scriptRuntimePath)
val replClassPath =
(kotlinPaths.compilerClasspath + kotlinPaths.compilerPath)
.joinToString(File.pathSeparator) { it.absolutePath }
paramList.add("-cp")
-1
View File
@@ -9,7 +9,6 @@ val fatJarContentsStripMetadata by configurations.creating
val fatJarContentsStripServices by configurations.creating
val compilerModules: Array<String> by rootProject.extra
val compilerManifestClassPath = "kotlin-stdlib.jar kotlin-reflect.jar kotlin-script-runtime.jar"
dependencies {
compilerModules.forEach { module ->
@@ -9,7 +9,6 @@ val fatJarContentsStripMetadata by configurations.creating
val fatJarContentsStripServices by configurations.creating
val compilerModules: Array<String> by rootProject.extra
val compilerManifestClassPath = "kotlin-stdlib.jar kotlin-reflect.jar kotlin-script-runtime.jar"
dependencies {
compilerModules.forEach { module ->
@@ -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
@@ -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"))
@@ -9,6 +9,7 @@ dependencies {
runtime(project(":kotlin-stdlib"))
runtime(project(":kotlin-script-runtime"))
runtime(project(":kotlin-reflect"))
runtime(commonDep("org.jetbrains.intellij.deps", "trove4j"))
}
noDefaultJar()
+12 -7
View File
@@ -17,8 +17,6 @@ val shrink =
findProperty("kotlin.build.proguard")?.toString()?.toBoolean()
?: hasProperty("teamcity")
val compilerManifestClassPath = "kotlin-stdlib.jar kotlin-reflect.jar kotlin-script-runtime.jar"
val fatJarContents by configurations.creating
val fatJarContentsStripMetadata by configurations.creating
@@ -31,6 +29,7 @@ val compile by configurations // maven plugin writes pom compile scope from com
val libraries by configurations.creating {
extendsFrom(compile)
}
val trove4jJar by configurations.creating
val default by configurations
default.extendsFrom(runtimeJar)
@@ -51,6 +50,7 @@ dependencies {
compile(project(":kotlin-stdlib"))
compile(project(":kotlin-script-runtime"))
compile(project(":kotlin-reflect"))
compile(commonDep("org.jetbrains.intellij.deps", "trove4j"))
libraries(project(":kotlin-annotations-jvm"))
libraries(
@@ -69,6 +69,8 @@ dependencies {
fatSourcesJarContents(it)
}
trove4jJar(intellijDep()) { includeIntellijCoreJarDependencies(project) { it.startsWith("trove4j") } }
fatJarContents(project(":core:builtins", configuration = "builtins"))
fatJarContents(commonDep("javax.inject"))
fatJarContents(commonDep("org.jline", "jline"))
@@ -79,7 +81,11 @@ dependencies {
fatJarContents(commonDep("org.jetbrains.kotlinx", "kotlinx-coroutines-core")) { isTransitive = false }
fatJarContents(intellijCoreDep()) { includeJars("intellij-core", "java-compatibility-1.0.1") }
fatJarContents(intellijDep()) { includeIntellijCoreJarDependencies(project, { !(it.startsWith("jdom") || it.startsWith("log4j")) }) }
fatJarContents(intellijDep()) {
includeIntellijCoreJarDependencies(project) {
!(it.startsWith("jdom") || it.startsWith("log4j") || it.startsWith("trove4j"))
}
}
fatJarContents(intellijDep()) { includeJars("jna-platform", "lz4-1.3.0") }
fatJarContentsStripServices(intellijDep("jps-standalone")) { includeJars("jps-model") }
fatJarContentsStripMetadata(intellijDep()) { includeJars("oro-2.0.8", "jdom", "log4j" ) }
@@ -136,10 +142,9 @@ val proguard by task<ProGuardTask> {
val pack = if (shrink) proguard else packCompiler
dist(
targetName = "$compilerBaseName.jar",
fromTask = pack
)
dist(targetName = "$compilerBaseName.jar", fromTask = pack) {
from(trove4jJar)
}
runtimeJarArtifactBy(pack, pack.outputs.files.singleFile) {
name = compilerBaseName
+12 -7
View File
@@ -17,8 +17,6 @@ val shrink =
findProperty("kotlin.build.proguard")?.toString()?.toBoolean()
?: hasProperty("teamcity")
val compilerManifestClassPath = "kotlin-stdlib.jar kotlin-reflect.jar kotlin-script-runtime.jar"
val fatJarContents by configurations.creating
val fatJarContentsStripMetadata by configurations.creating
@@ -31,6 +29,7 @@ val compile by configurations // maven plugin writes pom compile scope from com
val libraries by configurations.creating {
extendsFrom(compile)
}
val trove4jJar by configurations.creating
val default by configurations
default.extendsFrom(runtimeJar)
@@ -51,6 +50,7 @@ dependencies {
compile(project(":kotlin-stdlib"))
compile(project(":kotlin-script-runtime"))
compile(project(":kotlin-reflect"))
compile(commonDep("org.jetbrains.intellij.deps", "trove4j"))
libraries(project(":kotlin-annotations-jvm"))
libraries(
@@ -69,6 +69,8 @@ dependencies {
fatSourcesJarContents(it)
}
trove4jJar(intellijDep()) { includeIntellijCoreJarDependencies(project) { it.startsWith("trove4j") } }
fatJarContents(project(":core:builtins", configuration = "builtins"))
fatJarContents(commonDep("javax.inject"))
fatJarContents(commonDep("org.jline", "jline"))
@@ -79,7 +81,11 @@ dependencies {
fatJarContents(commonDep("org.jetbrains.kotlinx", "kotlinx-coroutines-core")) { isTransitive = false }
fatJarContents(intellijCoreDep()) { includeJars("intellij-core") }
fatJarContents(intellijDep()) { includeIntellijCoreJarDependencies(project, { !(it.startsWith("jdom") || it.startsWith("log4j")) }) }
fatJarContents(intellijDep()) {
includeIntellijCoreJarDependencies(project) {
!(it.startsWith("jdom") || it.startsWith("log4j") || it.startsWith("trove4j"))
}
}
when {
Platform[173].orLower() -> {
fatJarContents(intellijDep()) { includeJars("jna-platform") }
@@ -148,10 +154,9 @@ val proguard by task<ProGuardTask> {
val pack = if (shrink) proguard else packCompiler
dist(
targetName = "$compilerBaseName.jar",
fromTask = pack
)
dist(targetName = "$compilerBaseName.jar", fromTask = pack) {
from(trove4jJar)
}
runtimeJarArtifactBy(pack, pack.outputs.files.singleFile) {
name = compilerBaseName
+12 -7
View File
@@ -17,8 +17,6 @@ val shrink =
findProperty("kotlin.build.proguard")?.toString()?.toBoolean()
?: hasProperty("teamcity")
val compilerManifestClassPath = "kotlin-stdlib.jar kotlin-reflect.jar kotlin-script-runtime.jar"
val fatJarContents by configurations.creating
val fatJarContentsStripMetadata by configurations.creating
@@ -31,6 +29,7 @@ val compile by configurations // maven plugin writes pom compile scope from com
val libraries by configurations.creating {
extendsFrom(compile)
}
val trove4jJar by configurations.creating
val default by configurations
default.extendsFrom(runtimeJar)
@@ -51,6 +50,7 @@ dependencies {
compile(project(":kotlin-stdlib"))
compile(project(":kotlin-script-runtime"))
compile(project(":kotlin-reflect"))
compile(commonDep("org.jetbrains.intellij.deps", "trove4j"))
libraries(project(":kotlin-annotations-jvm"))
libraries(
@@ -69,6 +69,8 @@ dependencies {
fatSourcesJarContents(it)
}
trove4jJar(intellijDep()) { includeIntellijCoreJarDependencies(project) { it.startsWith("trove4j") } }
fatJarContents(project(":core:builtins", configuration = "builtins"))
fatJarContents(commonDep("javax.inject"))
fatJarContents(commonDep("org.jline", "jline"))
@@ -79,7 +81,11 @@ dependencies {
fatJarContents(commonDep("org.jetbrains.kotlinx", "kotlinx-coroutines-core")) { isTransitive = false }
fatJarContents(intellijCoreDep()) { includeJars("intellij-core") }
fatJarContents(intellijDep()) { includeIntellijCoreJarDependencies(project, { !(it.startsWith("jdom") || it.startsWith("log4j")) }) }
fatJarContents(intellijDep()) {
includeIntellijCoreJarDependencies(project) {
!(it.startsWith("jdom") || it.startsWith("log4j") || it.startsWith("trove4j"))
}
}
fatJarContents(intellijDep()) { includeJars("jna-platform", "lz4-1.3.0") }
fatJarContentsStripServices(intellijDep("jps-standalone")) { includeJars("jps-model") }
fatJarContentsStripMetadata(intellijDep()) { includeJars("oro-2.0.8", "jdom", "log4j" ) }
@@ -136,10 +142,9 @@ val proguard by task<ProGuardTask> {
val pack = if (shrink) proguard else packCompiler
dist(
targetName = "$compilerBaseName.jar",
fromTask = pack
)
dist(targetName = "$compilerBaseName.jar", fromTask = pack) {
from(trove4jJar)
}
runtimeJarArtifactBy(pack, pack.outputs.files.singleFile) {
name = compilerBaseName