Fix compileOnly dependencies in HMPP (KT-36469)
The `compileOnly` configuration of a source set was not included in the granular dependency transformation, which led to the dependencies from the configuration being excluded as unrequested during dependency processing. Fix this by properly including the compileOnly scope into the dependencies transformation. Issue #KT-36469 Fixed
This commit is contained in:
+23
@@ -395,6 +395,29 @@ class HierarchicalMppIT : BaseGradleIT() {
|
||||
return checkNotNull(parseKotlinSourceSetMetadataFromXml(document))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testCompileOnlyDependencyProcessingForMetadataCompilations() = with(Project("hierarchical-mpp-project-dependency")) {
|
||||
publishThirdPartyLib(withGranularMetadata = true)
|
||||
setupWorkingDir()
|
||||
gradleBuildScript().modify(::transformBuildScriptWithPluginsDsl)
|
||||
|
||||
gradleBuildScript("my-lib-foo").appendText("\ndependencies { \"jvmAndJsMainCompileOnly\"(kotlin(\"test-annotations-common\")) }")
|
||||
projectDir.resolve("my-lib-foo/src/jvmAndJsMain/kotlin/UseCompileOnlyDependency.kt").writeText(
|
||||
"""
|
||||
import kotlin.test.Test
|
||||
|
||||
class UseCompileOnlyDependency {
|
||||
@Test
|
||||
fun myTest() = Unit
|
||||
}
|
||||
""".trimIndent()
|
||||
)
|
||||
|
||||
build(":my-lib-foo:compileJvmAndJsMainKotlinMetadata") {
|
||||
assertSuccessful()
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testProcessingDependencyDeclaredInNonRootSourceSet() {
|
||||
publishThirdPartyLib(withGranularMetadata = true)
|
||||
|
||||
+2
-3
@@ -11,8 +11,7 @@ import org.gradle.api.tasks.*
|
||||
import org.jetbrains.kotlin.gradle.dsl.kotlinExtension
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet
|
||||
import org.jetbrains.kotlin.gradle.plugin.sources.KotlinDependencyScope.API_SCOPE
|
||||
import org.jetbrains.kotlin.gradle.plugin.sources.KotlinDependencyScope.IMPLEMENTATION_SCOPE
|
||||
import org.jetbrains.kotlin.gradle.plugin.sources.KotlinDependencyScope.*
|
||||
import org.jetbrains.kotlin.gradle.plugin.sources.getSourceSetHierarchy
|
||||
import org.jetbrains.kotlin.gradle.targets.metadata.ALL_COMPILE_METADATA_CONFIGURATION_NAME
|
||||
import org.jetbrains.kotlin.gradle.targets.metadata.KotlinMetadataTargetConfigurator
|
||||
@@ -70,7 +69,7 @@ open class TransformKotlinGranularMetadata
|
||||
GranularMetadataTransformation(
|
||||
project,
|
||||
kotlinSourceSet,
|
||||
listOf(API_SCOPE, IMPLEMENTATION_SCOPE),
|
||||
listOf(API_SCOPE, IMPLEMENTATION_SCOPE, COMPILE_ONLY_SCOPE),
|
||||
project.configurations.getByName(ALL_COMPILE_METADATA_CONFIGURATION_NAME),
|
||||
lazy {
|
||||
KotlinMetadataTargetConfigurator.dependsOnWithInterCompilationDependencies(project, kotlinSourceSet).map {
|
||||
|
||||
Reference in New Issue
Block a user