Skip to content

Commit baa6d44

Browse files
authored
Publish/pom: don't include test-fixtures dependencies as runtime (#772)
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 79808ce commit baa6d44

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
@@ -68,7 +69,17 @@ constructor(private val softwareComponentFactory: SoftwareComponentFactory) : Pl
6869
if (project.plugins.hasPlugin(ShadowPlugin::class.java)) {
6970
configureShadowPublishing(project, mavenPublication, softwareComponentFactory)
7071
} else {
71-
from(components.firstOrNull { c -> c.name == "javaPlatform" || c.name == "java" })
72+
val component =
73+
components.firstOrNull { c -> c.name == "javaPlatform" || c.name == "java" }
74+
if (component is AdhocComponentWithVariants) {
75+
listOf("testFixturesApiElements", "testFixturesRuntimeElements").forEach { cfg
76+
->
77+
configurations.findByName(cfg)?.apply {
78+
component.addVariantsFromConfiguration(this) { skip() }
79+
}
80+
}
81+
}
82+
from(component)
7283
}
7384
suppressPomMetadataWarningsFor("testApiElements")
7485
suppressPomMetadataWarningsFor("testJavadocElements")

0 commit comments

Comments
 (0)