Skip to content

Commit 5cc2353

Browse files
committed
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
1 parent 9657cfe commit 5cc2353

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

buildSrc/src/main/kotlin/PublishingHelperPlugin.kt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import org.gradle.api.attributes.Bundling
3030
import org.gradle.api.attributes.Category
3131
import org.gradle.api.attributes.LibraryElements
3232
import org.gradle.api.attributes.Usage
33+
import org.gradle.api.component.AdhocComponentWithVariants
3334
import org.gradle.api.component.SoftwareComponentFactory
3435
import org.gradle.api.plugins.JavaBasePlugin
3536
import org.gradle.api.publish.PublishingExtension
@@ -64,7 +65,17 @@ constructor(private val softwareComponentFactory: SoftwareComponentFactory) : Pl
6465
if (project.plugins.hasPlugin(ShadowPlugin::class.java)) {
6566
configureShadowPublishing(project, mavenPublication, softwareComponentFactory)
6667
} else {
67-
from(components.firstOrNull { c -> c.name == "javaPlatform" || c.name == "java" })
68+
val component =
69+
components.firstOrNull { c -> c.name == "javaPlatform" || c.name == "java" }
70+
if (component is AdhocComponentWithVariants) {
71+
listOf("testFixturesApiElements", "testFixturesRuntimeElements").forEach { cfg
72+
->
73+
configurations.findByName(cfg)?.apply {
74+
component.addVariantsFromConfiguration(this) { skip() }
75+
}
76+
}
77+
}
78+
from(component)
6879
}
6980
suppressPomMetadataWarningsFor("testApiElements")
7081
suppressPomMetadataWarningsFor("testJavadocElements")

0 commit comments

Comments
 (0)