From 606823f1e318dfe10bdf156dfe0577e3476f4d5e Mon Sep 17 00:00:00 2001 From: Markus Hintersteiner Date: Thu, 15 Dec 2022 18:02:02 +0100 Subject: [PATCH] Fix compose-helper module is exposed and gets published (#2430) Co-authored-by: Roman Zavarnitsyn Co-authored-by: Sentry Github Bot --- build.gradle.kts | 2 +- sentry-compose/build.gradle.kts | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index a5d08899c4..1a49ffe941 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -104,7 +104,7 @@ subprojects { } } - if (!this.name.contains("sample") && !this.name.contains("integration-tests") && this.name != "sentry-test-support") { + if (!this.name.contains("sample") && !this.name.contains("integration-tests") && this.name != "sentry-test-support" && this.name != "sentry-compose-helper") { apply() val sep = File.separator diff --git a/sentry-compose/build.gradle.kts b/sentry-compose/build.gradle.kts index 8b9abab586..d347191c27 100644 --- a/sentry-compose/build.gradle.kts +++ b/sentry-compose/build.gradle.kts @@ -1,4 +1,6 @@ import com.android.build.gradle.internal.tasks.LibraryAarJarsTask +import groovy.util.Node +import groovy.util.NodeList import io.gitlab.arturbosch.detekt.Detekt import org.jetbrains.dokka.gradle.DokkaTask @@ -159,3 +161,32 @@ dependencies { tasks.withType { mainScopeClassFiles.setFrom(embedComposeHelperConfig) } + +// we embed the sentry-compose-helper classes to the same .jar above +// so we need to exclude the dependency from the .pom publication and .module metadata +configure { + publications.withType(MavenPublication::class.java).all { + this.pom { + this.withXml { + (asNode().get("dependencies") as NodeList) + .flatMap { + if (it is Node) it.children() else NodeList() + } + .filterIsInstance() + .filter { dependency -> + val artifactIdNodes = dependency.get("artifactId") as NodeList + artifactIdNodes.any { + (it is Node && it.value().toString().contains("sentry-compose-helper")) + } + } + .forEach { dependency -> + dependency.parent().remove(dependency) + } + } + } + } +} + +tasks.withType { + enabled = false +}