Skip to content

Commit 47462c4

Browse files
romtsnclaude
andcommitted
build: Align SDK modules to one version through sentry-bom
Gradle resolves version conflicts per module, so a build could mix SDK modules of different versions, for example a newer sentry-android-core with an older sentry-android-fragment that the Gradle plugin or another library pulled in. That fails at runtime with NoSuchMethodError or the mixed versions check. The publish conventions now add sentry-bom as a platform to every published library module. Gradle then moves all SDK modules of a consumer to the highest version present. Maven does not apply the dependencyManagement of a dependency's POM, so Maven builds resolve as before. The BOM now also constrains sentry-android-distribution, which is released with the SDK. Refs #5105 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 5bf00d1 commit 47462c4

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

‎build-logic/src/main/kotlin/io/sentry/gradle/SentryPublishPlugin.kt‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ import org.gradle.kotlin.dsl.configure
1616
class SentryPublishPlugin : Plugin<Project> {
1717
override fun apply(project: Project) {
1818
project.configurePublishing(DistributionContainer::configureForJvm)
19+
// the BOMs are java-platform projects, so they do not depend on themselves
20+
project.plugins.withId("java-library") { project.alignWithBom("api") }
21+
project.plugins.withId("com.android.library") { project.alignWithBom("api") }
1922
}
2023
}
2124

@@ -26,9 +29,21 @@ class SentryPublishPlugin : Plugin<Project> {
2629
class SentryMultiplatformPublishPlugin : Plugin<Project> {
2730
override fun apply(project: Project) {
2831
project.configurePublishing(DistributionContainer::configureForMultiplatform)
32+
project.plugins.withId("org.jetbrains.kotlin.multiplatform") {
33+
project.alignWithBom("commonMainApi")
34+
}
2935
}
3036
}
3137

38+
/**
39+
* With sentry-bom as a platform, Gradle resolves all SDK modules of a consumer to one version, the
40+
* highest one present.
41+
*/
42+
private fun Project.alignWithBom(configuration: String) {
43+
val bom = dependencies.project(mapOf("path" to ":sentry-bom"))
44+
dependencies.add(configuration, dependencies.platform(bom))
45+
}
46+
3247
private fun Project.configurePublishing(
3348
configureDistributions: DistributionContainer.(Project) -> Unit
3449
) {

‎sentry-bom/build.gradle.kts‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ dependencies {
1313
!it.name.startsWith("sentry-samples") &&
1414
it.name != project.name &&
1515
!it.name.endsWith("-bom") &&
16-
!it.name.contains("test", ignoreCase = true) &&
17-
!it.name.contains("sentry-android-distribution")
16+
!it.name.contains("test", ignoreCase = true)
1817
}
1918
.forEach { project ->
2019
evaluationDependsOn(project.path)

0 commit comments

Comments
 (0)