From 5cc23535e8ea3aa01d38fa28c804fe6dbe411528 Mon Sep 17 00:00:00 2001 From: Robert Stupp Date: Fri, 5 Dec 2025 18:24:14 +0100 Subject: [PATCH] Publish/pom: don't include test-fixtures dependencies as runtime The list of dependencies in pom's includes the api/runtime elements of the test-fixtures, which is not what should be published, as it "pulls up" deps like junit, mockito and assertj as Maven runtime scope dependencies. This change fixes this --- buildSrc/src/main/kotlin/PublishingHelperPlugin.kt | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/buildSrc/src/main/kotlin/PublishingHelperPlugin.kt b/buildSrc/src/main/kotlin/PublishingHelperPlugin.kt index 3c22baaf..051bbfe2 100644 --- a/buildSrc/src/main/kotlin/PublishingHelperPlugin.kt +++ b/buildSrc/src/main/kotlin/PublishingHelperPlugin.kt @@ -30,6 +30,7 @@ import org.gradle.api.attributes.Bundling import org.gradle.api.attributes.Category import org.gradle.api.attributes.LibraryElements import org.gradle.api.attributes.Usage +import org.gradle.api.component.AdhocComponentWithVariants import org.gradle.api.component.SoftwareComponentFactory import org.gradle.api.plugins.JavaBasePlugin import org.gradle.api.publish.PublishingExtension @@ -64,7 +65,17 @@ constructor(private val softwareComponentFactory: SoftwareComponentFactory) : Pl if (project.plugins.hasPlugin(ShadowPlugin::class.java)) { configureShadowPublishing(project, mavenPublication, softwareComponentFactory) } else { - from(components.firstOrNull { c -> c.name == "javaPlatform" || c.name == "java" }) + val component = + components.firstOrNull { c -> c.name == "javaPlatform" || c.name == "java" } + if (component is AdhocComponentWithVariants) { + listOf("testFixturesApiElements", "testFixturesRuntimeElements").forEach { cfg + -> + configurations.findByName(cfg)?.apply { + component.addVariantsFromConfiguration(this) { skip() } + } + } + } + from(component) } suppressPomMetadataWarningsFor("testApiElements") suppressPomMetadataWarningsFor("testJavadocElements")