From 161935b881bac69737b41fae4e8111762725683b Mon Sep 17 00:00:00 2001 From: Jendrik Johannes Date: Tue, 28 Nov 2023 18:49:28 +0100 Subject: [PATCH] Gradle: do not publish test fixtures Signed-off-by: Jendrik Johannes --- ....hedera.hashgraph.maven-publish.gradle.kts | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/build-logic/project-plugins/src/main/kotlin/com.hedera.hashgraph.maven-publish.gradle.kts b/build-logic/project-plugins/src/main/kotlin/com.hedera.hashgraph.maven-publish.gradle.kts index c2d60b4e2fee..93779a3f0fd3 100644 --- a/build-logic/project-plugins/src/main/kotlin/com.hedera.hashgraph.maven-publish.gradle.kts +++ b/build-logic/project-plugins/src/main/kotlin/com.hedera.hashgraph.maven-publish.gradle.kts @@ -25,12 +25,27 @@ java { withSourcesJar() } +val javaComponent = components["java"] as AdhocComponentWithVariants + +plugins.withId("java-test-fixtures") { + // Disable publishing of test fixture if 'java-test-fixtures' plugin is used + // https://docs.gradle.org/current/userguide/java_testing.html#ex-disable-publishing-of-test-fixtures-variants + javaComponent.withVariantsFromConfiguration(configurations["testFixturesApiElements"]) { + skip() + } + javaComponent.withVariantsFromConfiguration(configurations["testFixturesRuntimeElements"]) { + skip() + } +} + val maven = publishing.publications.create("maven") { - from(components.getByName("java")) + from(javaComponent) versionMapping { - usage("java-api") { fromResolutionResult() } - usage("java-runtime") { fromResolutionResult() } + // Everything published takes the versions from the resolution result. + // These are the versions we define in 'hedera-dependency-versions' + // and use consistently in all modules. + allVariants { fromResolutionResult() } } pom {