Shade test jars from compiler used in Gradle tests

This fixes `VerifyError` for all integration tests calling
`KotlinTestUtils.findAndroidSdk()`.
The exception was thrown because `:kotlin-gradle-plugin-integration-tests`
was depending on both relocated intellij-core (from kotlin-compiler-embeddable)
and non-relocated intellij-core (transitevely through tests jars from compiler).

A call to `findAndroidSdk()` was triggering classloading
for `KotlinTestUtils` which had bytecode references to
`org.jetbrains.kotlin.idea.KotlinLanguage` loaded from the embeddable compiler
and to `com.intellij.lang.Language` loaded from non-relocated intellij-core.

`KotlinLanguage` from the embeddable compiler was a subclass of relocated
`org.jetbrains.kotlin.com.intellij.lang.Language` thus it was not
assignable to `com.intellij.lang.Language` causing `VerifyError`.

The solution is to create relocated jar combining the necessary test jars
from the compiler.
This commit is contained in:
Alexey Tsvetkov
2018-02-01 02:36:10 +03:00
parent 7cba035f80
commit 7c329b59b6
5 changed files with 39 additions and 4 deletions
@@ -0,0 +1,33 @@
/*
* Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the license/LICENSE.txt file.
*/
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import org.gradle.jvm.tasks.Jar
description = "Shaded test jars from compiler for Gradle integration tests"
plugins { `java` }
val packedJars by configurations.creating
val projectsToInclude = listOf(":compiler:tests-common",
":compiler:incremental-compilation-impl",
":kotlin-build-common")
dependencies {
for (projectName in projectsToInclude) {
packedJars(projectTests(projectName)) { isTransitive = false }
}
packedJars(intellijDep()) { includeJars("idea_rt") }
}
runtimeJar(rewriteDepsToShadedCompiler(
task<ShadowJar>("shadowJar") {
from(packedJars)
}
))