Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
01efed6
build: Switch to JDK 21 and upgrade Mockito, Robolectric and Error Prone
markushi Oct 9, 2026
8ff189d
build: Compile tests for JDK 21 and fix buildSrc JVM target
markushi Oct 9, 2026
3dc76c0
build: Compile with a JDK 21 toolchain from a build-logic convention โ€ฆ
markushi Oct 13, 2026
26b8a60
docs(kafka): Explain the explicit double cast at the latency call site
markushi Oct 13, 2026
9788085
build: Compile the samples and their tests with the toolchain JDK
markushi Oct 13, 2026
f6de52d
Format code
getsentry-bot Oct 13, 2026
6e81176
build: Drop the now-unused JvmTarget imports from the samples
markushi Oct 13, 2026
1c7fbf3
build: Clarify the jvm-targets plugin comments and rename its helper
markushi Oct 13, 2026
5c8907d
Merge branch 'build/jdk-21' of github.com:getsentry/sentry-java into โ€ฆ
markushi Oct 13, 2026
7bd342c
build: Require JDK 21 to run Gradle again
markushi Oct 13, 2026
37b01cf
build: Keep the Spring Boot 2 sample apps on their published bytecodeโ€ฆ
markushi Oct 13, 2026
d663f01
ci: Drop the stale Java version from the build job name
markushi Oct 13, 2026
445f5e4
build: Keep Robolectric at 4.15 and leave its test environment untouched
markushi Oct 13, 2026
2de047f
build: Move the Java 8 release pin into the jvm-targets convention plโ€ฆ
markushi Oct 14, 2026
561324b
build: Drop the Error Prone and NullAway code fixes, they move to theโ€ฆ
markushi Oct 15, 2026
2c629ba
Merge remote-tracking branch 'origin/main' into build/jdk-21
markushi Oct 15, 2026
ddae2a9
ci: Drop the stale Java version from the build job name
markushi Oct 15, 2026
aaa1ef0
fix(core): Suppress the new Error Prone and javac 21 findings in the โ€ฆ
markushi Oct 15, 2026
fef4772
fix(core): Resolve the remaining Error Prone and javac 21 findings inโ€ฆ
markushi Oct 15, 2026
61c4352
build: Move the JDK and bytecode level decisions into the io.sentry.cโ€ฆ
markushi Oct 15, 2026
c667f66
Address PR comments
markushi Oct 15, 2026
4d4654d
test(android): Make the flush timeout verifies match the real log call
markushi Oct 15, 2026
982954a
chore(core): Reword the JDK 21 suppression comments
markushi Oct 15, 2026
38288e8
build: Keep only the javac unit test targets inside afterEvaluate
markushi Oct 16, 2026
e387384
Merge remote-tracking branch 'origin/main' into build/jdk-21
markushi Oct 16, 2026
a2345fc
build: Drop afterEvaluate, pin the Kotlin API level and rename the coโ€ฆ
markushi Oct 16, 2026
975708e
Fix JDK 21 findings in sentry-android-core (#6261)
markushi Oct 20, 2026
1ee7acc
Fix JDK 21 findings in the Spring modules (#6260)
markushi Oct 20, 2026
0f3f8bc
Fix JDK 21 findings in the JVM integrations (#6259)
markushi Oct 20, 2026
2b6f9fa
Merge branch 'main' into build/jdk-21
markushi Oct 20, 2026
17e2b85
fix multiplatform target compilations
markushi Oct 21, 2026
374ff7d
Merge remote-tracking branch 'origin/main' into build/jdk-21
markushi Oct 21, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/agp-matrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
uses: actions/setup-java@b843ebf9b913146b38da2eaa7aeddf76074ae1ad # v6.1.0
with:
distribution: 'temurin'
java-version: '17'
java-version: '21'

- name: Setup Gradle
uses: gradle/actions/setup-gradle@3f5f9adaf7d9fecd50b5935e54106014257a94e6 # v6.4.0
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ concurrency:
jobs:
build:
# Job name is a required status check in the main branch ruleset; keep it stable.
name: Build Job ubuntu-latest - Java 17
name: Build Job ubuntu-latest
runs-on: ubuntu-latest

env:
Expand All @@ -29,7 +29,7 @@ jobs:
uses: actions/setup-java@b843ebf9b913146b38da2eaa7aeddf76074ae1ad # v6.1.0
with:
distribution: 'temurin'
java-version: '17'
java-version: '21'

# Workaround for https://github.com/gradle/actions/issues/21 to use config cache
- name: Cache buildSrc
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
uses: actions/setup-java@b843ebf9b913146b38da2eaa7aeddf76074ae1ad # v6.1.0
with:
distribution: 'temurin'
java-version: '17'
java-version: '21'

- name: Setup Gradle
uses: gradle/actions/setup-gradle@3f5f9adaf7d9fecd50b5935e54106014257a94e6 # v6.4.0
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/enforce-license-compliance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
uses: actions/setup-java@b843ebf9b913146b38da2eaa7aeddf76074ae1ad # v6.1.0
with:
distribution: 'temurin'
java-version: '17'
java-version: '21'

- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/format-code.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
uses: actions/setup-java@b843ebf9b913146b38da2eaa7aeddf76074ae1ad # v6.1.0
with:
distribution: 'temurin'
java-version: '17'
java-version: '21'

- name: Setup Gradle
uses: gradle/actions/setup-gradle@3f5f9adaf7d9fecd50b5935e54106014257a94e6 # v6.4.0
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/generate-javadocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
uses: actions/setup-java@b843ebf9b913146b38da2eaa7aeddf76074ae1ad # v6.1.0
with:
distribution: 'temurin'
java-version: '17'
java-version: '21'

- name: Setup Gradle
uses: gradle/actions/setup-gradle@3f5f9adaf7d9fecd50b5935e54106014257a94e6 # v6.4.0
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/integration-tests-macrobenchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
uses: actions/setup-java@b843ebf9b913146b38da2eaa7aeddf76074ae1ad # v6.1.0
with:
distribution: 'temurin'
java-version: '17'
java-version: '21'

- name: Setup Gradle
uses: gradle/actions/setup-gradle@3f5f9adaf7d9fecd50b5935e54106014257a94e6 # v6.4.0
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/integration-tests-size.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
uses: actions/setup-java@b843ebf9b913146b38da2eaa7aeddf76074ae1ad # v6.1.0
with:
distribution: "temurin"
java-version: "17"
java-version: "21"

# Workaround for https://github.com/gradle/actions/issues/21 to use config cache
- name: Cache buildSrc
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/integration-tests-ui-critical.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
uses: actions/setup-java@b843ebf9b913146b38da2eaa7aeddf76074ae1ad # v6.1.0
with:
distribution: 'temurin'
java-version: '17'
java-version: '21'

- name: Setup Gradle
uses: gradle/actions/setup-gradle@3f5f9adaf7d9fecd50b5935e54106014257a94e6 # v6.4.0
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/integration-tests-ui.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
uses: actions/setup-java@b843ebf9b913146b38da2eaa7aeddf76074ae1ad # v6.1.0
with:
distribution: 'temurin'
java-version: '17'
java-version: '21'

- name: Setup Gradle
uses: gradle/actions/setup-gradle@3f5f9adaf7d9fecd50b5935e54106014257a94e6 # v6.4.0
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
uses: actions/setup-java@b843ebf9b913146b38da2eaa7aeddf76074ae1ad # v6.1.0
with:
distribution: 'temurin'
java-version: '17'
java-version: '21'

- name: Setup Gradle
uses: gradle/actions/setup-gradle@3f5f9adaf7d9fecd50b5935e54106014257a94e6 # v6.4.0
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/spring-boot-2-matrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
uses: actions/setup-java@b843ebf9b913146b38da2eaa7aeddf76074ae1ad # v6.1.0
with:
distribution: 'temurin'
java-version: '17'
java-version: '21'

# Workaround for https://github.com/gradle/actions/issues/21 to use config cache
- name: Cache buildSrc
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/spring-boot-3-matrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
uses: actions/setup-java@b843ebf9b913146b38da2eaa7aeddf76074ae1ad # v6.1.0
with:
distribution: 'temurin'
java-version: '17'
java-version: '21'

# Workaround for https://github.com/gradle/actions/issues/21 to use config cache
- name: Cache buildSrc
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/spring-boot-4-matrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
uses: actions/setup-java@b843ebf9b913146b38da2eaa7aeddf76074ae1ad # v6.1.0
with:
distribution: 'temurin'
java-version: '17'
java-version: '21'

# Workaround for https://github.com/gradle/actions/issues/21 to use config cache
- name: Cache buildSrc
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/system-tests-backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ jobs:
uses: actions/setup-java@b843ebf9b913146b38da2eaa7aeddf76074ae1ad # v6.1.0
with:
distribution: 'temurin'
java-version: '17'
java-version: '21'

- name: Setup Gradle
uses: gradle/actions/setup-gradle@3f5f9adaf7d9fecd50b5935e54106014257a94e6 # v6.4.0
Expand Down
4 changes: 3 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ You are welcome to use whatever tools you prefer for making a contribution. Howe

# Requirements

The project requires you to run JDK 17.
The project requires you to run JDK 21 or newer. Compilation and tests always happen on JDK 21
through a [toolchain](https://docs.gradle.org/current/userguide/toolchains.html), so a newer JDK
runs the build but never changes its output.

## Android

Expand Down
6 changes: 6 additions & 0 deletions build-logic/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,16 @@ plugins {
dependencies {
implementation(libs.animalsniffer.gradle.plugin)
implementation(libs.spotlessLib)
compileOnly(libs.kotlin.gradle.plugin)
compileOnly(libs.android.gradle.plugin)
}

gradlePlugin {
plugins {
register("sentryJdkTarget") {
id = "io.sentry.jdk-target"
implementationClass = "io.sentry.gradle.JdkTargetConvention"
}
register("sentryAnimalSniffer") {
id = "io.sentry.animalsniffer"
implementationClass = "io.sentry.gradle.SentryAnimalSnifferPlugin"
Expand Down
2 changes: 2 additions & 0 deletions build-logic/settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ dependencyResolutionManagement {
repositories {
mavenCentral()
gradlePluginPortal()
// AGP is only published to Google's repository.
google()
}
versionCatalogs {
create("libs") {
Expand Down
116 changes: 116 additions & 0 deletions build-logic/src/main/kotlin/io/sentry/gradle/JdkTargetConvention.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
package io.sentry.gradle

import com.android.build.gradle.BaseExtension
import org.gradle.api.JavaVersion
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.artifacts.VersionCatalogsExtension
import org.gradle.api.plugins.JavaBasePlugin
import org.gradle.api.plugins.JavaPluginExtension
import org.gradle.api.tasks.compile.JavaCompile
import org.gradle.jvm.toolchain.JavaLanguageVersion
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.dsl.KotlinAndroidProjectExtension
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinAndroidTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile

/** The JDK every module compiles and tests with, whatever JDK runs Gradle. */
private val BUILD_JDK = JavaLanguageVersion.of(21)

/** The level the SDK publishes, so that Java 8 consumers can still use it. */
private val PUBLISHED_JAVA_VERSION = JavaVersion.VERSION_1_8

/**
* Holds every toolchain, bytecode level decision and compilation option of a module. It does the
* following
* - sample apps target the build JDK (21)
* - unit test code will target the build JDK (21) (required for Mockito 5)
* - published JVM modules main code pins the Java 1.8 release, for Java and for Kotlin
* - published Android modules main code targets Java 1.8
* - minSdk is set for Android libraries
*/
class JdkTargetConvention : Plugin<Project> {
override fun apply(project: Project) {
project.plugins.withType(JavaBasePlugin::class.java) {
project.extensions.getByType(JavaPluginExtension::class.java).toolchain {
languageVersion.set(BUILD_JDK)
}
Comment thread
markushi marked this conversation as resolved.
}

project.plugins.withId("com.vanniktech.maven.publish") {
Comment thread
markushi marked this conversation as resolved.
// Only works for non-android modules
// See https://issuetracker.google.com/issues/278800528
project.plugins.withId("java-library") {
project.tasks.named("compileJava", JavaCompile::class.java) {
options.release.set(PUBLISHED_JAVA_VERSION.majorVersion.toInt())
}
}
// -Xjdk-release is the Kotlin counterpart of release: without it Kotlin resolves against the
// build JDK and happily compiles e.g. Files.readString() into Java 8 bytecode. The version
// follows jvmTarget, which the modules that publish a higher level set themselves.
project.plugins.withId("org.jetbrains.kotlin.jvm") {
project.tasks.named("compileKotlin", KotlinJvmCompile::class.java) {
compilerOptions.freeCompilerArgs.add(
Comment thread
markushi marked this conversation as resolved.
compilerOptions.jvmTarget.map { "-Xjdk-release=${it.target}" }
)
}
}
}
Comment thread
cursor[bot] marked this conversation as resolved.

project.plugins.withId("com.android.library") {
val android = project.extensions.getByType(BaseExtension::class.java)
Comment thread
markushi marked this conversation as resolved.
android.compileOptions {
sourceCompatibility = PUBLISHED_JAVA_VERSION
targetCompatibility = PUBLISHED_JAVA_VERSION
}
android.defaultConfig { aarMetadata { minCompileSdk = project.minSdk() } }
}

listOf("com.android.library", "com.android.application").forEach { pluginId ->
project.plugins.withId(pluginId) { project.targetBuildJdkForUnitTests() }
}
}

private fun Project.minSdk(): Int =
Comment thread
markushi marked this conversation as resolved.
extensions
.getByType(VersionCatalogsExtension::class.java)
.named("libs")
.findVersion("minSdk")
.orElseThrow { IllegalStateException("libs.versions.minSdk is missing") }
.requiredVersion
.toInt()

/**
* Mockito 5 and mockito-kotlin 6 are built for Java 11, so test code - which is never published -
* cannot share the Java 8 target of the main code. AGP has no per variant compileOptions, so this
* goes through the Kotlin compilations: their compile task providers are configured after AGP
* wrote its own compileOptions, which an apply time configureEach would lose against.
*/
private fun Project.targetBuildJdkForUnitTests() {
plugins.withId("org.jetbrains.kotlin.android") {
extensions.getByType(KotlinAndroidProjectExtension::class.java).target.targetBuildJdk()
}
plugins.withId("org.jetbrains.kotlin.multiplatform") {
extensions
.getByType(KotlinMultiplatformExtension::class.java)
.targets
.withType(KotlinAndroidTarget::class.java)
.configureEach { targetBuildJdk() }
}
}

private fun KotlinAndroidTarget.targetBuildJdk() {
compilations.configureEach {
if (name.endsWith("UnitTest")) {
compileTaskProvider.configure {
compilerOptions.jvmTarget.set(JvmTarget.fromTarget(BUILD_JDK.toString()))
}
compileJavaTaskProvider?.configure {
sourceCompatibility = BUILD_JDK.toString()
targetCompatibility = BUILD_JDK.toString()
}
}
}
}
}
27 changes: 5 additions & 22 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
alias(libs.plugins.sentry) apply false
Comment thread
sentry-warden[bot] marked this conversation as resolved.
}

check(JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_21)) {
"This build requires JDK 21 or newer, but runs on JDK ${JavaVersion.current()}."
}

buildscript {
repositories {
google()
Expand Down Expand Up @@ -111,6 +115,7 @@

subprojects {
apply { plugin("io.sentry.spotless") }
apply { plugin("io.sentry.jdk-target") }

plugins.withId(Config.QualityPlugins.detektPlugin) {
configure<DetektExtension> {
Expand Down Expand Up @@ -159,34 +164,12 @@
// and do it ourselves
configure(JavaLibrary(JavadocJar.None(), sourcesJar = true))
}

configure<JavaPluginExtension> {
withJavadocJar()

sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
}

// AGP 9 defaults Android modules to Java 11. Pin the published library modules back
// to Java 8 so their bytecode stays consumable by Java 8 projects, mirroring the
// java-library pin above.
plugins.withId("com.android.library") {
configure<com.android.build.gradle.BaseExtension> {
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

// AGP 9 defaults the AAR metadata minCompileSdk to the library's compileSdk,
// which would force every consumer onto that compile SDK. Pin it to our minSdk
// so consumers remain free to compile against any SDK we support, as before.
defaultConfig {
aarMetadata { minCompileSdk = libs.versions.minSdk.get().toInt() }
}
}
}

Check warning on line 172 in build.gradle.kts

View check run for this annotation

@sentry/warden / warden: check-code-attribution

โš ๏ธ Missing THIRD_PARTY_NOTICES.md entry

**build.gradle.kts** โ€” The `assignAarTypes` helper (adapted from AndroidX `MavenUploadHelper.kt`, Apache 2.0) has a complete file header but no matching THIRD_PARTY_NOTICES.md entry; add one with Source URL, License name, Copyright, Scope (`build.gradle.kts`), and full license text.
apply<MavenPublishPlugin>()

afterEvaluate {
Expand Down
6 changes: 0 additions & 6 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
`kotlin-dsl`
}

tasks.withType<KotlinCompile>().configureEach {
Comment thread
markushi marked this conversation as resolved.
compilerOptions.jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17
}
Loading
Loading