Fix dependencies rewriting and gradle integration tests after applying rewriting
This commit is contained in:
@@ -20,26 +20,87 @@ val packagesToRelocate =
|
|||||||
"org.picocontainer",
|
"org.picocontainer",
|
||||||
"jline",
|
"jline",
|
||||||
"gnu",
|
"gnu",
|
||||||
"javax.inject",
|
|
||||||
"org.fusesource")
|
"org.fusesource")
|
||||||
|
|
||||||
fun Project.embeddableCompiler(taskName: String = "embeddable", body: Jar.() -> Unit = {}): Jar {
|
// The shaded compiler "dummy" is used to rewrite dependencies in projects that are used with the embeddable compiler
|
||||||
|
// on the runtime and use some shaded dependencies from the compiler
|
||||||
|
// To speed-up rewriting process we want to have this dummy as small as possible.
|
||||||
|
// But due to the shadow plugin bug (https://github.com/johnrengelman/shadow/issues/262) it is not possible to use
|
||||||
|
// packagesToRelocate list to for the include list. Therefore the exclude list has to be created.
|
||||||
|
val packagesToExcludeFromDummy =
|
||||||
|
listOf("org/jetbrains/kotlin/**",
|
||||||
|
"org/intellij/lang/annotations/**",
|
||||||
|
"org/jetbrains/jps/**",
|
||||||
|
"META-INF/**",
|
||||||
|
"com/sun/jna/**",
|
||||||
|
"com/thoughtworks/xstream/**",
|
||||||
|
"javaslang/**",
|
||||||
|
"*.proto",
|
||||||
|
"messages/**",
|
||||||
|
"net/sf/cglib/**",
|
||||||
|
"one/util/streamex/**",
|
||||||
|
"org/iq80/snappy/**",
|
||||||
|
"org/jline/**",
|
||||||
|
"org/json/**",
|
||||||
|
"org/xmlpull/**",
|
||||||
|
"*.txt")
|
||||||
|
|
||||||
val compilerJar = configurations.create("compilerJar")
|
private fun ShadowJar.configureEmbeddableCompilerRelocation(withJavaxInject: Boolean = true) {
|
||||||
|
relocate("com.google.protobuf", "org.jetbrains.kotlin.protobuf")
|
||||||
|
packagesToRelocate.forEach {
|
||||||
|
relocate(it, "$kotlinEmbeddableRootPackage.$it")
|
||||||
|
}
|
||||||
|
if (withJavaxInject) {
|
||||||
|
relocate("javax.inject", "$kotlinEmbeddableRootPackage.javax.inject")
|
||||||
|
}
|
||||||
|
relocate("org.fusesource", "$kotlinEmbeddableRootPackage.org.fusesource") {
|
||||||
|
// TODO: remove "it." after #KT-12848 get addressed
|
||||||
|
exclude("org.fusesource.jansi.internal.CLibrary")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun Project.compilerShadowJar(taskName: String, body: ShadowJar.() -> Unit): Jar {
|
||||||
|
|
||||||
|
val compilerJar = configurations.getOrCreate("compilerJar")
|
||||||
dependencies.add(compilerJar.name, dependencies.project(":kotlin-compiler", configuration = "runtimeJar"))
|
dependencies.add(compilerJar.name, dependencies.project(":kotlin-compiler", configuration = "runtimeJar"))
|
||||||
|
|
||||||
return task<ShadowJar>(taskName) {
|
return task<ShadowJar>(taskName) {
|
||||||
destinationDir = File(buildDir, "libs")
|
destinationDir = File(buildDir, "libs")
|
||||||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||||
from(compilerJar)
|
from(compilerJar)
|
||||||
relocate("com.google.protobuf", "org.jetbrains.kotlin.protobuf")
|
body()
|
||||||
packagesToRelocate.forEach {
|
}
|
||||||
relocate(it, "$kotlinEmbeddableRootPackage.$it")
|
}
|
||||||
|
|
||||||
|
fun Project.embeddableCompiler(taskName: String = "embeddable", body: ShadowJar.() -> Unit = {}): Jar =
|
||||||
|
compilerShadowJar(taskName) {
|
||||||
|
configureEmbeddableCompilerRelocation()
|
||||||
|
body()
|
||||||
}
|
}
|
||||||
relocate("org.fusesource", "$kotlinEmbeddableRootPackage.org.fusesource") {
|
|
||||||
// TODO: remove "it." after #KT-12848 get addressed
|
fun Project.compilerDummyForDependenciesRewriting(taskName: String = "compilerDummy", body: ShadowJar.() -> Unit = {}): Jar =
|
||||||
exclude("org.fusesource.jansi.internal.CLibrary")
|
compilerShadowJar(taskName) {
|
||||||
|
exclude(packagesToExcludeFromDummy)
|
||||||
|
body()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const val COMPILER_DUMMY_JAR_CONFIGURATION_NAME = "compilerDummyJar"
|
||||||
|
|
||||||
|
fun Project.compilerDummyJar(task: Jar, body: Jar.() -> Unit = {}) {
|
||||||
|
task.body()
|
||||||
|
addArtifact(COMPILER_DUMMY_JAR_CONFIGURATION_NAME, task, task)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Project.embeddableCompilerDummyForDependenciesRewriting(taskName: String = "embeddable", body: Jar.() -> Unit = {}): Jar {
|
||||||
|
val compilerDummyJar = configurations.getOrCreate("compilerDummyJar")
|
||||||
|
dependencies.add(compilerDummyJar.name,
|
||||||
|
dependencies.project(":kotlin-compiler-embeddable", configuration = COMPILER_DUMMY_JAR_CONFIGURATION_NAME))
|
||||||
|
|
||||||
|
return task<ShadowJar>(taskName) {
|
||||||
|
destinationDir = File(buildDir, "libs")
|
||||||
|
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||||
|
from(compilerDummyJar)
|
||||||
|
configureEmbeddableCompilerRelocation(withJavaxInject = false)
|
||||||
body()
|
body()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -56,7 +117,7 @@ fun Project.rewriteDepsToShadedJar(originalJarTask: Jar, shadowJarTask: Zip, bod
|
|||||||
}
|
}
|
||||||
shadowJarTask.apply {
|
shadowJarTask.apply {
|
||||||
dependsOn(originalJarTask)
|
dependsOn(originalJarTask)
|
||||||
from(originalJarTask)
|
from(originalJarTask)// { include("**") }
|
||||||
classifier = "shadow"
|
classifier = "shadow"
|
||||||
}
|
}
|
||||||
dependsOn(shadowJarTask)
|
dependsOn(shadowJarTask)
|
||||||
@@ -65,4 +126,5 @@ fun Project.rewriteDepsToShadedJar(originalJarTask: Jar, shadowJarTask: Zip, bod
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Project.rewriteDepsToShadedCompiler(originalJarTask: Jar, body: Jar.() -> Unit = {}): Jar = rewriteDepsToShadedJar(originalJarTask, embeddableCompiler(), body)
|
fun Project.rewriteDepsToShadedCompiler(originalJarTask: Jar, body: Jar.() -> Unit = {}): Jar =
|
||||||
|
rewriteDepsToShadedJar(originalJarTask, embeddableCompilerDummyForDependenciesRewriting(), body)
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
||||||
|
import org.gradle.api.internal.artifacts.publish.ArchivePublishArtifact
|
||||||
|
import org.gradle.jvm.tasks.Jar
|
||||||
|
|
||||||
description = "Annotation Processor wrapper for Kotlin"
|
description = "Annotation Processor wrapper for Kotlin"
|
||||||
|
|
||||||
@@ -22,12 +24,20 @@ projectTest {
|
|||||||
workingDir = projectDir
|
workingDir = projectDir
|
||||||
}
|
}
|
||||||
|
|
||||||
val originalJar by task<ShadowJar> {
|
//noDefaultJar()
|
||||||
from(packedJars)
|
//tasks.remove(tasks.findByName("jar"))
|
||||||
from(the<JavaPluginConvention>().sourceSets.getByName("main").output)
|
//
|
||||||
}
|
//runtimeJar(task<ShadowJar>("jar")) {
|
||||||
|
// from(packedJars)
|
||||||
runtimeJar(rewriteDepsToShadedCompiler(originalJar))
|
// from(the<JavaPluginConvention>().sourceSets.getByName("main").output)
|
||||||
|
// configureRelocation()
|
||||||
|
//}
|
||||||
|
runtimeJar(rewriteDepsToShadedCompiler(
|
||||||
|
task<ShadowJar>("shadowJar") {
|
||||||
|
from(packedJars)
|
||||||
|
from(the<JavaPluginConvention>().sourceSets.getByName("main").output)
|
||||||
|
}
|
||||||
|
))
|
||||||
sourcesJar()
|
sourcesJar()
|
||||||
javadocJar()
|
javadocJar()
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,8 @@ dependencies {
|
|||||||
testCompile project(path: ':compiler:incremental-compilation-impl', configuration: 'tests-jar')
|
testCompile project(path: ':compiler:incremental-compilation-impl', configuration: 'tests-jar')
|
||||||
|
|
||||||
testCompile 'org.jetbrains.kotlin:gradle-api:2.2'
|
testCompile 'org.jetbrains.kotlin:gradle-api:2.2'
|
||||||
|
|
||||||
|
testRuntime project(path: ':kotlin-android-extensions', configuration: 'runtimeJar')
|
||||||
}
|
}
|
||||||
|
|
||||||
test.dependsOn(":kotlin-allopen:install",
|
test.dependsOn(":kotlin-allopen:install",
|
||||||
|
|||||||
@@ -32,9 +32,9 @@ dependencies {
|
|||||||
compileOnly project(':compiler:incremental-compilation-impl')
|
compileOnly project(':compiler:incremental-compilation-impl')
|
||||||
|
|
||||||
compile project(':kotlin-stdlib')
|
compile project(':kotlin-stdlib')
|
||||||
compile project(':kotlin-android-extensions')
|
compileOnly project(':kotlin-android-extensions')
|
||||||
compile project(':kotlin-build-common')
|
compileOnly project(':kotlin-build-common')
|
||||||
compile project(':kotlin-compiler-runner')
|
compileOnly project(':kotlin-compiler-runner')
|
||||||
compileOnly project(':kotlin-annotation-processing')
|
compileOnly project(':kotlin-annotation-processing')
|
||||||
compileOnly project(':kotlin-annotation-processing-gradle')
|
compileOnly project(':kotlin-annotation-processing-gradle')
|
||||||
|
|
||||||
@@ -44,6 +44,8 @@ dependencies {
|
|||||||
|
|
||||||
runtime project(path: ':kotlin-compiler-embeddable', configuration: "runtimeJar")
|
runtime project(path: ':kotlin-compiler-embeddable', configuration: "runtimeJar")
|
||||||
runtime project(path: ':kotlin-annotation-processing-gradle', configuration: "runtimeJar")
|
runtime project(path: ':kotlin-annotation-processing-gradle', configuration: "runtimeJar")
|
||||||
|
runtime project(path: ':kotlin-android-extensions', configuration: 'runtimeJar')
|
||||||
|
runtime project(path: ':kotlin-compiler-runner', configuration: 'runtimeJar')
|
||||||
|
|
||||||
agp25CompileOnly 'com.android.tools.build:gradle:3.0.0-alpha1'
|
agp25CompileOnly 'com.android.tools.build:gradle:3.0.0-alpha1'
|
||||||
agp25CompileOnly 'org.codehaus.groovy:groovy-all:2.3.9'
|
agp25CompileOnly 'org.codehaus.groovy:groovy-all:2.3.9'
|
||||||
@@ -53,6 +55,8 @@ dependencies {
|
|||||||
|
|
||||||
testCompileOnly project(':compiler')
|
testCompileOnly project(':compiler')
|
||||||
testCompile project (path: ':kotlin-build-common', configuration: 'tests-jar')
|
testCompile project (path: ':kotlin-build-common', configuration: 'tests-jar')
|
||||||
|
testCompile project(':kotlin-android-extensions')
|
||||||
|
testCompile project(':kotlin-compiler-runner')
|
||||||
testCompile project(':kotlin-test::kotlin-test-junit')
|
testCompile project(':kotlin-test::kotlin-test-junit')
|
||||||
testCompile "junit:junit:4.12"
|
testCompile "junit:junit:4.12"
|
||||||
testCompileOnly project(':kotlin-annotation-processing')
|
testCompileOnly project(':kotlin-annotation-processing')
|
||||||
|
|||||||
@@ -6,13 +6,18 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile(project(":kotlin-stdlib"))
|
runtime(project(":kotlin-stdlib"))
|
||||||
compile(project(":kotlin-script-runtime"))
|
runtime(project(":kotlin-script-runtime"))
|
||||||
compile(project(":kotlin-reflect"))
|
runtime(project(":kotlin-reflect"))
|
||||||
}
|
}
|
||||||
|
|
||||||
noDefaultJar()
|
noDefaultJar()
|
||||||
|
|
||||||
|
// dummy is used for rewriting dependencies to the shaded packages in the embeddable compiler
|
||||||
|
compilerDummyJar(compilerDummyForDependenciesRewriting("compilerDummy") {
|
||||||
|
classifier = "dummy"
|
||||||
|
})
|
||||||
|
|
||||||
runtimeJar(embeddableCompiler())
|
runtimeJar(embeddableCompiler())
|
||||||
|
|
||||||
sourcesJar()
|
sourcesJar()
|
||||||
|
|||||||
Reference in New Issue
Block a user