From bbf64b14d7ede0da1583a769455850b34f86f23b Mon Sep 17 00:00:00 2001 From: Sebastian Sellmair Date: Tue, 20 Jun 2023 10:49:01 +0200 Subject: [PATCH] [Gradle] Implement KT59446TransformationOnTransitiveJavaDependencyTest ^KT-59446 In Progress (cherry picked from commit ec46c82a13a122f9c5aee132aa8cff91c226c55e) --- ...formationOnTransitiveJavaDependencyTest.kt | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 libraries/tools/kotlin-gradle-plugin/src/functionalTest/kotlin/org/jetbrains/kotlin/gradle/regressionTests/KT59446TransformationOnTransitiveJavaDependencyTest.kt diff --git a/libraries/tools/kotlin-gradle-plugin/src/functionalTest/kotlin/org/jetbrains/kotlin/gradle/regressionTests/KT59446TransformationOnTransitiveJavaDependencyTest.kt b/libraries/tools/kotlin-gradle-plugin/src/functionalTest/kotlin/org/jetbrains/kotlin/gradle/regressionTests/KT59446TransformationOnTransitiveJavaDependencyTest.kt new file mode 100644 index 0000000000000..3fe40a4fe9aa4 --- /dev/null +++ b/libraries/tools/kotlin-gradle-plugin/src/functionalTest/kotlin/org/jetbrains/kotlin/gradle/regressionTests/KT59446TransformationOnTransitiveJavaDependencyTest.kt @@ -0,0 +1,52 @@ +/* + * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +@file:Suppress("FunctionName") + +package org.jetbrains.kotlin.gradle.regressionTests + +import org.jetbrains.kotlin.gradle.dsl.multiplatformExtension +import org.jetbrains.kotlin.gradle.plugin.ide.dependencyResolvers.resolveMetadata +import org.jetbrains.kotlin.gradle.plugin.mpp.MetadataDependencyResolution +import org.jetbrains.kotlin.gradle.util.buildProject +import org.jetbrains.kotlin.gradle.util.buildProjectWithMPP +import kotlin.test.Test + +class KT59446TransformationOnTransitiveJavaDependencyTest { + @Test + fun `test - transform transitive java dependency`() { + val rootProject = buildProject() + val projectA = buildProjectWithMPP(projectBuilder = { withParent(rootProject).withName("a") }) + val projectB = buildProjectWithMPP(projectBuilder = { withParent(rootProject).withName("b") }) + val projectJava = buildProject(projectBuilder = { withParent(rootProject).withName("java") }) + + /** + * a -> b -> java + */ + projectJava.plugins.apply("java-library") + + projectA.multiplatformExtension.jvm() + projectB.multiplatformExtension.jvm() + + projectB.multiplatformExtension.sourceSets.getByName("commonMain").dependencies { + api(project(":java")) + } + + projectA.multiplatformExtension.sourceSets.getByName("commonMain").dependencies { + api(project(":b")) + } + + /* + Call transformation + Exception was: + org.jetbrains.kotlin.gradle.plugin.KotlinPluginLifecycle$IllegalLifecycleException: Future was not completed yet 'Kotlin Plugin Lifecycle: (project ':java') *not started*' + at org.jetbrains.kotlin.gradle.utils.FutureImpl.getOrThrow(Future.kt:113) + at org.jetbrains.kotlin.gradle.utils.LenientFutureImpl.getOrThrow(Future.kt:138) + at org.jetbrains.kotlin.gradle.plugin.mpp.GranularMetadataTransformation.toModuleDependencyIdentifier(GranularMetadataTransformation.kt:303) + at org.jetbrains.kotlin.gradle.plugin.mpp.GranularMetadataTransformation.processDependency(GranularMetadataTransformation.kt:260) + */ + projectA.multiplatformExtension.sourceSets.getByName("commonMain").resolveMetadata() + } +} \ No newline at end of file