diff --git a/tools/kotlin-native-gradle-plugin/build.gradle b/tools/kotlin-native-gradle-plugin/build.gradle index a390feb2a48..ed9e428a186 100644 --- a/tools/kotlin-native-gradle-plugin/build.gradle +++ b/tools/kotlin-native-gradle-plugin/build.gradle @@ -112,6 +112,7 @@ shadowJar { classifier = null relocate('org.jetbrains.kotlinx', 'shadow.org.jetbrains.kotlinx') relocate('org.jetbrains.kotlin.compilerRunner', 'shadow.org.jetbrains.kotlin.compilerRunner') + relocate('org.jetbrains.kotlin.konan', 'shadow.org.jetbrains.kotlin.konan') relocate('org.jetbrains.kotlin.gradle', 'shadow.org.jetbrains.kotlin.gradle') { exclude('org.jetbrains.kotlin.gradle.plugin.experimental.**') exclude('org.jetbrains.kotlin.gradle.plugin.konan.**') @@ -157,10 +158,6 @@ pluginUnderTestMetadata { test { dependsOn shadowJar - classpath = configurations.testRuntimeClasspath + - sourceSets.test.output + - files(shadowJar.archivePath) + - configurations.shadow systemProperty("kotlin.version", kotlinVersion) systemProperty("kotlin.repo", kotlinCompilerRepo) if (project.hasProperty("konan.home")) { diff --git a/tools/kotlin-native-gradle-plugin/src/test/kotlin/ExperimentalPluginTests.kt b/tools/kotlin-native-gradle-plugin/src/test/kotlin/ExperimentalPluginTests.kt index 9a0a3d7fddc..d16030f6997 100644 --- a/tools/kotlin-native-gradle-plugin/src/test/kotlin/ExperimentalPluginTests.kt +++ b/tools/kotlin-native-gradle-plugin/src/test/kotlin/ExperimentalPluginTests.kt @@ -847,23 +847,40 @@ class ExperimentalPluginTests { @Test fun `Plugin should provide a correct serialization compiler plugin`() { - withProject { - pluginManager.apply("kotlinx-serialization-native") - repositories.apply { - jcenter() - maven { it.setUrl("http://kotlin.bintray.com/kotlin-eap") } - maven { it.setUrl("http://kotlin.bintray.com/kotlin-dev") } - maven { it.setUrl(MultiplatformSpecification.KOTLIN_REPO) } - } - evaluate() - tasks.withType(KotlinNativeCompile::class.java).all { - val compileClassPath = it.compilerPluginClasspath - assertNotNull(compileClassPath) - val files = compileClassPath.files - assertTrue(files.isNotEmpty(), "No compiler plugins in the classpath") - assertEquals(1, files.size, "More than one compiler plugin in the classpath") - assertTrue(files.single().absolutePath.contains("kotlin-serialization-unshaded"), "No unshaded version of serialization plugin in the classpath") - } + val project = KonanProject.createEmpty(projectDirectory).apply { + buildFile.writeText(""" + import org.jetbrains.kotlin.gradle.plugin.experimental.tasks.KotlinNativeCompile + + plugins { + id 'kotlin-native' + id 'kotlinx-serialization-native' + } + + repositories { + maven { url "http://kotlin.bintray.com/kotlin-eap" } + maven { url "http://kotlin.bintray.com/kotlin-dev" } + maven { url "${MultiplatformSpecification.KOTLIN_REPO}" } + } + + def assertTrue(boolean cond, String message) { + if (!cond) { + throw AssertionError(message) + } + } + + task assertClassPath { + doLast { + tasks.withType(KotlinNativeCompile.class).all { + def compileClassPath = it.compilerPluginClasspath + assertTrue(compileClassPath != null, "compileClassPath should not be null") + assertTrue(!compileClassPath.isEmpty(), "No compiler plugins in the classpath") + assertTrue(compileClassPath.singleFile.absolutePath.contains("kotlin-serialization-unshaded"), + "No unshaded version of serialization plugin in the classpath") + } + } + } + """.trimIndent()) } + project.createRunner().withArguments("assertClassPath").build() } } diff --git a/tools/kotlin-native-gradle-plugin/src/test/kotlin/ToolingModelTests.kt b/tools/kotlin-native-gradle-plugin/src/test/kotlin/ToolingModelTests.kt index 61d547a6261..68a0f91ad6b 100644 --- a/tools/kotlin-native-gradle-plugin/src/test/kotlin/ToolingModelTests.kt +++ b/tools/kotlin-native-gradle-plugin/src/test/kotlin/ToolingModelTests.kt @@ -129,7 +129,7 @@ open class ToolingModelTests { } import org.jetbrains.kotlin.gradle.plugin.model.* - import org.jetbrains.kotlin.konan.target.CompilerOutputKind + import shadow.org.jetbrains.kotlin.konan.target.CompilerOutputKind public void assertEquals( T actual,