Move embeddable compiler shading logic to buildSrc, implement rewriteDeps task

the task takes a jar an a shading task (like the one that creates embeddable
compiler) and rewrites jar's dependencies to the shaded ones according the
the shade task.
This commit is contained in:
Ilya Chernikov
2017-10-12 14:00:03 +02:00
parent 5babf89245
commit fb70227868
3 changed files with 72 additions and 47 deletions
+1 -47
View File
@@ -1,44 +1,11 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
description = "Kotlin Compiler (embeddable)"
buildscript {
repositories {
jcenter()
}
dependencies {
classpath("com.github.jengelman.gradle.plugins:shadow:${property("versions.shadow")}")
}
}
plugins {
`java`
}
val compilerJar by configurations.creating
val kotlinEmbeddableRootPackage = "org.jetbrains.kotlin"
val packagesToRelocate =
listOf(
// "com.intellij",
"com.google",
"com.sampullara",
"org.apache",
"org.jdom",
"org.picocontainer",
"jline",
"gnu",
"javax.inject",
"org.fusesource")
dependencies {
val compile by configurations
compilerJar(projectRuntimeJar(":kotlin-compiler"))
compile(project(":kotlin-stdlib"))
compile(project(":kotlin-script-runtime"))
compile(project(":kotlin-reflect"))
@@ -46,20 +13,7 @@ dependencies {
noDefaultJar()
runtimeJar(task<ShadowJar>("embeddable")) {
destinationDir = File(buildDir, "libs")
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
// dependsOn(":kotlin-compiler:proguard")
from(compilerJar)
relocate("com.google.protobuf", "org.jetbrains.kotlin.protobuf")
packagesToRelocate.forEach {
relocate(it, "$kotlinEmbeddableRootPackage.$it")
}
relocate("org.fusesource", "$kotlinEmbeddableRootPackage.org.fusesource") {
// TODO: remove "it." after #KT-12848 get addressed
exclude("org.fusesource.jansi.internal.CLibrary")
}
}
runtimeJar(embeddableCompiler())
sourcesJar()
javadocJar()