Skip to content

Commit fa34787

Browse files
runningcodeclaude
andcommitted
build(samples): Prepare the samples to build outside the SDK build
The samples and Android integration tests are about to become their own builds, which include the SDK build. Several things tie them to the SDK build today: - They call buildSrc's Config, which other builds cannot see. They now name the coordinates directly, the way a customer's build would. - Five samples' shadowJar tasks use buildSrc's MergeSpringMetadataAction, which only the samples use. It moves to build-logic, which the new builds can include. - They pick the Kotlin stdlib version with KotlinCompilerVersion, a compiler-internal class that came from buildSrc's classpath. They now use KGP's getKotlinPluginVersion(), which returns the same version. - AGP came from Config.AGP on the root buildscript classpath. A composite build must use a single AGP version, so it now comes from the version catalog, and each build's settings applies the AGP matrix job's VERSION_AGP override. - The javac -Xlint:all -Werror flags came from the root allprojects block. They move to the io.sentry.jdk-target convention, which every subproject already applies and the new builds can apply too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent e48e7ab commit fa34787

29 files changed

Lines changed: 128 additions & 107 deletions

File tree

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,23 @@ private val PUBLISHED_JAVA_VERSION = JavaVersion.VERSION_1_8
3333
* archives are checked for it
3434
* - published Android modules main code targets Java 1.8
3535
* - minSdk is set for Android libraries
36+
* - javac warnings fail the build
3637
*/
3738
class JdkTargetConvention : Plugin<Project> {
3839
override fun apply(project: Project) {
40+
project.tasks.withType(JavaCompile::class.java).configureEach {
41+
options.compilerArgs.addAll(
42+
listOf(
43+
"-Xlint:all",
44+
"-Werror",
45+
"-Xlint:-classfile",
46+
"-Xlint:-processing",
47+
"-Xlint:-try",
48+
"-Xlint:-options",
49+
)
50+
)
51+
}
52+
3953
project.plugins.withType(JavaBasePlugin::class.java) {
4054
project.extensions.getByType(JavaPluginExtension::class.java).toolchain {
4155
languageVersion.set(BUILD_JDK)

buildSrc/src/main/java/MergeSpringMetadataAction.kt renamed to build-logic/src/main/kotlin/io/sentry/gradle/MergeSpringMetadataAction.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
package io.sentry.gradle
2+
13
import java.net.URI
24
import java.nio.file.FileSystems
35
import java.nio.file.Files

‎build.gradle.kts‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,14 @@ plugins {
2727
alias(libs.plugins.spring.dependency.management) apply false
2828
id("io.sentry.javadoc.aggregate")
2929
alias(libs.plugins.sentry) apply false
30+
alias(libs.plugins.android.application) apply false
3031
}
3132

3233
buildscript {
3334
repositories {
3435
google()
3536
}
3637
dependencies {
37-
classpath(Config.BuildPlugins.androidGradle)
38-
3938
// add classpath of sentry android gradle plugin
4039
// classpath("io.sentry:sentry-android-gradle-plugin:{version}")
4140

@@ -102,9 +101,6 @@ allprojects {
102101
TestLogEvent.FAILED
103102
)
104103
}
105-
withType<JavaCompile>().configureEach {
106-
options.compilerArgs.addAll(arrayOf("-Xlint:all", "-Werror", "-Xlint:-classfile", "-Xlint:-processing", "-Xlint:-try", "-Xlint:-options"))
107-
}
108104
}
109105
}
110106

‎buildSrc/src/main/java/Config.kt‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
11

22
object Config {
3-
val AGP = System.getenv("VERSION_AGP") ?: "9.4.0"
43
val kotlinStdLib = "stdlib-jdk8"
54
val kotlinStdLibVersionAndroid = "1.9.24"
65
val kotlinTestJunit = "test-junit"
76

8-
object BuildPlugins {
9-
val androidGradle = "com.android.tools.build:gradle:$AGP"
10-
}
11-
127
object Android {
138
val abiFilters = listOf("x86", "armeabi-v7a", "x86_64", "arm64-v8a")
149

‎gradle/libs.versions.toml‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ retrofit = "2.9.0"
3838
room2 = "2.8.4"
3939
room3 = "3.0.0-rc01"
4040
sagp = "6.13.0"
41-
# Compile-time only, for the AGP types the build-logic convention plugins use. The AGP that
42-
# actually runs the build comes from the root buildscript (Config.AGP, overridable via VERSION_AGP).
41+
# The AGP matrix job overrides this with the VERSION_AGP env var, through each build's settings.
4342
agp = "9.4.0"
4443
sqlite = "2.6.2"
4544
sqliteRc = "2.7.0-rc01" # Required by Room3 3.0.0-rc*
@@ -59,7 +58,8 @@ compileSdkMinor = "2"
5958
minSdk = "21"
6059

6160
[plugins]
62-
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
61+
android-application = { id = "com.android.application", version.ref = "agp" }
62+
kotlin-android ={ id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
6363
kotlin-spring = { id = "org.jetbrains.kotlin.plugin.spring", version.ref = "kotlin" }
6464
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
6565
kotlin-compose = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }

‎sentry-android-integration-tests/sentry-uitest-android-critical/build.gradle.kts‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import io.gitlab.arturbosch.detekt.Detekt
2+
import org.jetbrains.kotlin.gradle.plugin.getKotlinPluginVersion
23

34
plugins {
45
id("com.android.application")
@@ -35,14 +36,12 @@ android {
3536
buildFeatures { compose = true }
3637
composeOptions { kotlinCompilerExtensionVersion = libs.versions.composeCompiler.get() }
3738
androidComponents.beforeVariants {
38-
it.enable = !Config.Android.shouldSkipDebugVariant(it.buildType)
39+
it.enable = it.buildType != "debug"
3940
}
4041
}
4142

4243
dependencies {
43-
implementation(
44-
kotlin(Config.kotlinStdLib, org.jetbrains.kotlin.config.KotlinCompilerVersion.VERSION)
45-
)
44+
implementation(kotlin("stdlib-jdk8", getKotlinPluginVersion()))
4645
implementation(libs.androidx.activity.compose)
4746
implementation(libs.androidx.compose.foundation)
4847
implementation(libs.androidx.compose.material3)

‎sentry-android-integration-tests/sentry-uitest-android/build.gradle.kts‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import io.gitlab.arturbosch.detekt.Detekt
22
import net.ltgt.gradle.errorprone.errorprone
3+
import org.jetbrains.kotlin.gradle.plugin.getKotlinPluginVersion
34

45
plugins {
56
id("com.android.application")
@@ -86,9 +87,7 @@ if (applySentryIntegrations) {
8687
}
8788

8889
dependencies {
89-
implementation(
90-
kotlin(Config.kotlinStdLib, org.jetbrains.kotlin.config.KotlinCompilerVersion.VERSION)
91-
)
90+
implementation(kotlin("stdlib-jdk8", getKotlinPluginVersion()))
9291

9392
if (applySentryIntegrations) {
9493
implementation(projects.sentryAndroid)

‎sentry-android-integration-tests/test-app-size/build.gradle.kts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ android {
3131
targetCompatibility = JavaVersion.VERSION_17
3232
}
3333
androidComponents.beforeVariants {
34-
it.enable = !Config.Android.shouldSkipDebugVariant(it.buildType)
34+
it.enable = it.buildType != "debug"
3535
}
3636
}
3737

‎sentry-samples/sentry-samples-android/build.gradle.kts‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import io.sentry.android.gradle.extensions.InstrumentationFeature
55
import io.sentry.android.gradle.extensions.SentryPluginExtension
66
import org.apache.tools.ant.taskdefs.condition.Os
77
import org.gradle.internal.extensions.stdlib.capitalized
8+
import org.jetbrains.kotlin.gradle.plugin.getKotlinPluginVersion
89

910
plugins {
1011
id("com.android.application")
@@ -64,7 +65,7 @@ android {
6465
}
6566
}
6667

67-
ndk { abiFilters.addAll(Config.Android.abiFilters) }
68+
ndk { abiFilters.addAll(listOf("x86", "armeabi-v7a", "x86_64", "arm64-v8a")) }
6869
}
6970

7071
lint {
@@ -172,9 +173,7 @@ sqldelight {
172173
}
173174

174175
dependencies {
175-
implementation(
176-
kotlin(Config.kotlinStdLib, org.jetbrains.kotlin.config.KotlinCompilerVersion.VERSION)
177-
)
176+
implementation(kotlin("stdlib-jdk8", getKotlinPluginVersion()))
178177

179178
implementation(projects.sentryAndroid)
180179
implementation(projects.sentryAndroidFragment)

‎sentry-samples/sentry-samples-netflix-dgs/build.gradle.kts‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import org.jetbrains.kotlin.config.KotlinCompilerVersion
1+
import io.sentry.gradle.MergeSpringMetadataAction
2+
import org.jetbrains.kotlin.gradle.plugin.getKotlinPluginVersion
23
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
34

45
plugins {
@@ -22,8 +23,8 @@ java.targetCompatibility = JavaVersion.VERSION_1_8
2223
dependencies {
2324
implementation(platform(libs.springboot2.bom))
2425
implementation(libs.springboot.starter.web)
25-
implementation(Config.Libs.kotlinReflect)
26-
implementation(kotlin(Config.kotlinStdLib, KotlinCompilerVersion.VERSION))
26+
implementation("org.jetbrains.kotlin:kotlin-reflect")
27+
implementation(kotlin("stdlib-jdk8", getKotlinPluginVersion()))
2728
implementation(projects.sentrySpringBootStarter)
2829
implementation(projects.sentryGraphql)
2930
implementation(platform("com.netflix.graphql.dgs:graphql-dgs-platform-dependencies:4.9.2"))

0 commit comments

Comments
 (0)