Open osipxd opened 1 month ago
However, I've found a workaround:
// Exclude test fixtures from publication, as we use it only internally
plugins.withId("org.gradle.java-test-fixtures") {
val component = components["java"] as AdhocComponentWithVariants
component.withVariantsFromConfiguration(configurations["testFixturesApiElements"]) { skip() }
component.withVariantsFromConfiguration(configurations["testFixturesRuntimeElements"]) { skip() }
// Workaround to not publish test fixtures sources added by com.vanniktech.maven.publish plugin
// TODO: Remove as soon as https://github.com/vanniktech/gradle-maven-publish-plugin/issues/779 closed
afterEvaluate {
component.withVariantsFromConfiguration(configurations["testFixturesSourcesElements"]) { skip() }
}
}
Having one of the 2 options built into the plugin is reasonable, I'll look into that.
Could you also open a feature request for Gradle directly? This would be benefitial for either option, for option 1 it would mean that we could read whatever config they have to disable the publication and for option 2 it would mean we can use their API internally. It would also remove the need to access internal types like DefaultJvmSoftwareComponent
.
Created the issue for Gradle:
Oh, it looks like it is actually possible to disable test fixtures publication without internal APIs, so I've updated the workaround to get rid of internal APIs usage.
Context
I need to use test fixtures only internally between modules, so I don't want to publish them into Maven Central. I have the following code to exclude test fixtures from publication:
However, gradle-maven-publish-plugin forces publication of
testFixturesSourcesElements
whether or not other test fixture components are published.Proposal
I see two options:
testFixturesSourcesElements
publication if other test fixtures components are skipped from publication