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
@@ -15,12 +15,12 @@ dependencies {
testCompile project(':kotlin-test:kotlin-test-jvm')
testCompile project(path: ':kotlin-compiler-embeddable', configuration: 'runtimeJar')
testCompile (project(path: ':kotlin-gradle-plugin-test-utils-embeddable', configuration: 'runtimeJar'))
testCompile project(path: ':examples:annotation-processor-example')
testCompile project(':kotlin-stdlib-jre8')
testCompile project(':kotlin-reflect')
testCompile project(':kotlin-android-extensions')
testCompile project(path: ':kotlin-build-common', configuration: 'tests-jar')
testCompile project(path: ':compiler:incremental-compilation-impl', configuration: 'tests-jar')
testCompile gradleApi()
@@ -1,6 +1,6 @@
package org.jetbrains.kotlin.gradle
import com.intellij.openapi.util.io.FileUtil
import org.jetbrains.kotlin.com.intellij.openapi.util.io.FileUtil
import org.gradle.api.logging.LogLevel
import org.jetbrains.kotlin.gradle.util.*
import org.junit.After
@@ -17,7 +17,7 @@
package org.jetbrains.kotlin.gradle
import org.gradle.api.logging.LogLevel
import com.intellij.openapi.util.io.FileUtil
import org.jetbrains.kotlin.com.intellij.openapi.util.io.FileUtil
import org.jetbrains.kotlin.gradle.plugin.CopyClassesToJavaOutputStatus
import org.jetbrains.kotlin.gradle.tasks.USING_INCREMENTAL_COMPILATION_MESSAGE
import org.jetbrains.kotlin.gradle.plugin.*