Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# Changelog

> [!WARNING]
> SDK 9.0.0 will raise the minimum supported Java and Android versions:
> SDK 9.0.0 will raise the minimum supported Java, Android, and Kotlin versions:
> - Java 8 support will be dropped. SDK 9.0.0 requires Java 11+. See [#6469](https://github.com/getsentry/sentry-java/issues/6469).
> - The Android `minSdk` will be raised from 21 to 24. See [#5508](https://github.com/getsentry/sentry-java/issues/5508).
> - Apps that compile Kotlin will need Kotlin 2.0+. See [#6473](https://github.com/getsentry/sentry-java/issues/6473).

## Unreleased

Expand All @@ -12,6 +13,7 @@
- Remove the deprecated `io.sentry.android.core.LoadClass`. Use `io.sentry.util.LoadClass` instead ([#6594](https://github.com/getsentry/sentry-java/pull/6594))
- `SentryOptions.getIgnoredErrors()`, `getIgnoredTransactions()`, `getIgnoredCheckIns()` and `getIgnoredSpanOrigins()` now return `List<String>` instead of `List<FilterString>`, matching their setters ([#6489](https://github.com/getsentry/sentry-java/pull/6489))
- The SDK is now compiled for Java 11 instead of Java 8. JVM applications need Java 11 or newer ([#6459](https://github.com/getsentry/sentry-java/pull/6459))
- The SDK is now compiled with Kotlin language/API version 2.1. Apps that compile Kotlin need Kotlin 2.0 or newer, up from 1.8. Apps written only in Java are not affected. Modules that depend on `kotlin-stdlib` now pin 2.1.21, up from 1.9.24. The other modules use the app's own stdlib ([#6646](https://github.com/getsentry/sentry-java/pull/6646))
- Default trace context status to `ok` when an active span has no explicit status ([#6418](https://github.com/getsentry/sentry-java/pull/6418))
- Remove the deprecated `traceSampling` option (`SentryOptions.setTraceSampling`/`isTraceSampling` and the `io.sentry.traces.trace-sampling` manifest key) ([#6415](https://github.com/getsentry/sentry-java/pull/6415))
- Use `tracePropagationTargets` to control which URL-aware outgoing requests get tracing headers.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,12 @@ 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.KotlinJvmProjectExtension
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinAndroidTarget
import org.jetbrains.kotlin.gradle.targets.jvm.KotlinJvmTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask
import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile

/** The JDK every module compiles and tests with, whatever JDK runs Gradle. */
Expand All @@ -23,6 +27,12 @@ private val BUILD_JDK = JavaLanguageVersion.of(21)
/** The level the SDK publishes. */
private val PUBLISHED_JAVA_VERSION = JavaVersion.VERSION_11

/**
* The Kotlin language and API version the SDK publishes. A Kotlin compiler reads metadata up to one
* version newer than its own, so apps that compile Kotlin need Kotlin 2.0 or newer.
*/
private val PUBLISHED_KOTLIN_VERSION = KotlinVersion.KOTLIN_2_1

/**
* Holds every toolchain, bytecode level decision and compilation option of a module. It does the
* following
Expand All @@ -34,6 +44,9 @@ private val PUBLISHED_JAVA_VERSION = JavaVersion.VERSION_11
* - published Android modules main code targets Java 11
* - minSdk is set for Android libraries
* - javac warnings fail the build
* - Kotlin module names stay the project name
* - published modules main code compiles Kotlin with the published language/API version
* - Kotlin doesn't warn about the deprecated language/API version the SDK targets
*/
class JdkTargetConvention : Plugin<Project> {
override fun apply(project: Project) {
Expand Down Expand Up @@ -112,6 +125,52 @@ class JdkTargetConvention : Plugin<Project> {
listOf("com.android.library", "com.android.application").forEach { pluginId ->
project.plugins.withId(pluginId) { project.targetBuildJdkForUnitTests() }
}

project.keepKotlinModuleNameWithoutGroup()

// Test code isn't published, so it keeps the compiler's default and may use newer features.
project.plugins.withId("com.vanniktech.maven.publish") {
project.tasks.withType(KotlinCompilationTask::class.java).configureEach {
if (!name.contains("Test")) {
compilerOptions.languageVersion.set(PUBLISHED_KOTLIN_VERSION)
compilerOptions.apiVersion.set(PUBLISHED_KOTLIN_VERSION)
}
}
}

// The SDK targets the oldest language/API version its consumers' Kotlin can read, which newer
// compilers deprecate. That's deliberate, so the warning on every compilation is noise.
project.tasks.withType(KotlinCompilationTask::class.java).configureEach {
compilerOptions.freeCompilerArgs.add("-Xsuppress-version-warnings")
}
}

/**
* KGP 2.4 prefixes the Kotlin module name with the group, e.g. `io.sentry:sentry-okhttp`. R8 copies
* that name into the names of the `.kotlin_module` entries it writes under `META-INF`, and app
* bundles reject the colon, so the module name stays the project name, as before KGP 2.4.
*/
private fun Project.keepKotlinModuleNameWithoutGroup() {
val moduleName = name
plugins.withId("org.jetbrains.kotlin.jvm") {
extensions.getByType(KotlinJvmProjectExtension::class.java).compilerOptions.moduleName.set(
moduleName
)
}
plugins.withId("org.jetbrains.kotlin.android") {
extensions.getByType(KotlinAndroidProjectExtension::class.java).compilerOptions.moduleName.set(
moduleName
)
}
plugins.withId("org.jetbrains.kotlin.multiplatform") {
val targets = extensions.getByType(KotlinMultiplatformExtension::class.java).targets
targets.withType(KotlinJvmTarget::class.java).configureEach {
compilerOptions.moduleName.set(moduleName)
}
targets.withType(KotlinAndroidTarget::class.java).configureEach {
compilerOptions.moduleName.set(moduleName)
}
}
}

private fun Project.minSdk(): Int =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
package io.sentry.gradle

import org.gradle.api.GradleException
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.plugins.ExtensionAware
import org.gradle.kotlin.dsl.create
import org.jetbrains.kotlin.gradle.dsl.abi.AbiValidationExtension
import org.jetbrains.kotlin.gradle.dsl.abi.AbiValidationMultiplatformExtension
import org.jetbrains.kotlin.gradle.dsl.KotlinTopLevelExtension
import org.jetbrains.kotlin.gradle.dsl.abi.ExperimentalAbiValidation

private val KOTLIN_PLUGIN_IDS =
Expand Down Expand Up @@ -34,14 +31,12 @@ class SentryApiValidationPlugin : Plugin<Project> {
}

private fun enable(project: Project, extension: ApiValidationExtension) {
val kotlin = project.extensions.getByName("kotlin") as ExtensionAware
when (val abi = kotlin.extensions.getByName("abiValidation")) {
is AbiValidationMultiplatformExtension -> abi.also { it.enabled.set(true) }
is AbiValidationExtension -> abi.also { it.enabled.set(true) }
else -> throw GradleException("Unexpected abiValidation extension: ${abi.javaClass.name}")
}.filters {
// Lazy, because the module configures the extension after this plugin has been applied.
exclude { byNames.addAll(extension.ignoredPackages.map { it.map { pkg -> "$pkg.**" } }) }
val kotlin = project.extensions.getByName("kotlin") as KotlinTopLevelExtension
kotlin.abiValidation {
filters {
// Lazy, because the module configures the extension after this plugin has been applied.
exclude { byNames.addAll(extension.ignoredPackages.map { it.map { pkg -> "$pkg.**" } }) }
}
}
}
}
2 changes: 1 addition & 1 deletion buildSrc/src/main/java/Config.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

object Config {
val kotlinStdLib = "stdlib-jdk8"
val kotlinStdLibVersionAndroid = "1.9.24"
val kotlinStdLibVersionAndroid = "2.1.21"
val kotlinTestJunit = "test-junit"

object Android {
Expand Down
3 changes: 1 addition & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ feign = "13.17"
gummyBears = "0.16.0"
jackson = "2.18.3"
jetbrainsCompose = "1.6.11"
kotlin = "2.3.21"
kotlin-compatible-version = "1.9"
kotlin = "2.4.21"
ksp = "2.3.14"
ktorClient = "3.6.1"
logback = "1.2.9"
Expand Down
2 changes: 0 additions & 2 deletions sentry-android-distribution/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_11
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion

plugins {
id("com.android.library")
Expand Down Expand Up @@ -34,7 +33,6 @@ android {

kotlin {
compilerOptions.jvmTarget = JVM_11
compilerOptions.languageVersion = KotlinVersion.KOTLIN_1_9
explicitApi()
}

Expand Down
1 change: 1 addition & 0 deletions sentry-android-fragment/api/sentry-android-fragment.api
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public final class io/sentry/android/fragment/FragmentLifecycleState : java/lang
public static final field STOPPED Lio/sentry/android/fragment/FragmentLifecycleState;
public static final field VIEW_CREATED Lio/sentry/android/fragment/FragmentLifecycleState;
public static final field VIEW_DESTROYED Lio/sentry/android/fragment/FragmentLifecycleState;
public static fun getEntries ()Lkotlin/enums/EnumEntries;
public static fun valueOf (Ljava/lang/String;)Lio/sentry/android/fragment/FragmentLifecycleState;
public static fun values ()[Lio/sentry/android/fragment/FragmentLifecycleState;
}
Expand Down
3 changes: 0 additions & 3 deletions sentry-android-fragment/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import io.gitlab.arturbosch.detekt.Detekt
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion

plugins {
id("com.android.library")
Expand Down Expand Up @@ -36,8 +35,6 @@ android {

kotlin {
compilerOptions.jvmTarget = JvmTarget.JVM_11
compilerOptions.languageVersion = KotlinVersion.KOTLIN_1_9
compilerOptions.apiVersion = KotlinVersion.KOTLIN_1_9
}

testOptions {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
-dontwarn timber.log.Timber$Tree
-dontwarn kotlin.Deprecated
-dontwarn kotlin.Function
-dontwarn kotlin.jvm.JvmField
-dontwarn kotlin.jvm.JvmStatic
-dontwarn kotlin.jvm.functions.Function2
-dontwarn kotlin.jvm.functions.Function3
Expand Down
3 changes: 0 additions & 3 deletions sentry-android-navigation/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import io.gitlab.arturbosch.detekt.Detekt
import org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_11
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion

plugins {
id("com.android.library")
Expand Down Expand Up @@ -37,8 +36,6 @@ android {

kotlin {
compilerOptions.jvmTarget = JVM_11
compilerOptions.languageVersion = KotlinVersion.KOTLIN_1_9
compilerOptions.apiVersion = KotlinVersion.KOTLIN_1_9
}

testOptions {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ public final class io/sentry/compose/navigation3/SentryNavEffectKt {

public final class io/sentry/compose/navigation3/SentryNavOptions {
public static final field $stable I
public synthetic fun <init> (ZZZILkotlin/jvm/internal/DefaultConstructorMarker;)V
public fun equals (Ljava/lang/Object;)Z
public final fun getCaptureBackStack ()Z
public final fun getEnableNavigationBreadcrumbs ()Z
Expand Down
3 changes: 0 additions & 3 deletions sentry-android-navigation3/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import io.gitlab.arturbosch.detekt.Detekt
import org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_11
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion

plugins {
id("com.android.library")
Expand Down Expand Up @@ -35,8 +34,6 @@ android {

kotlin {
compilerOptions.jvmTarget = JVM_11
compilerOptions.languageVersion = KotlinVersion.KOTLIN_1_9
compilerOptions.apiVersion = KotlinVersion.KOTLIN_1_9
}

testOptions {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ class BackStackConverterTest {
"nil" to null,
"nested" to mapOf("inner" to "value"),
"tags" to listOf("a", "b", "c"),
"array" to arrayOf("a", 1, false, PrivacyMode.PUBLIC, 'z'),
"array" to arrayOf<Any>("a", 1, false, PrivacyMode.PUBLIC, 'z'),
"ints" to intArrayOf(1, 2, 3),
"chars" to charArrayOf('a', 'b'),
"bytes" to byteArrayOf(4, 5),
Expand Down
3 changes: 0 additions & 3 deletions sentry-android-replay/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import io.gitlab.arturbosch.detekt.Detekt
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
import org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask

plugins {
Expand Down Expand Up @@ -45,8 +44,6 @@ android {

kotlin {
compilerOptions.jvmTarget = JvmTarget.JVM_11
compilerOptions.languageVersion = KotlinVersion.KOTLIN_1_9
compilerOptions.apiVersion = KotlinVersion.KOTLIN_1_9
}

testOptions {
Expand Down
2 changes: 0 additions & 2 deletions sentry-android-sqlite/api/sentry-android-sqlite.api
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ public final class io/sentry/android/sqlite/BuildConfig {

public final class io/sentry/android/sqlite/SentrySupportSQLiteOpenHelper : androidx/sqlite/db/SupportSQLiteOpenHelper {
public static final field Companion Lio/sentry/android/sqlite/SentrySupportSQLiteOpenHelper$Companion;
public synthetic fun <init> (Landroidx/sqlite/db/SupportSQLiteOpenHelper;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
public fun close ()V
public static final fun create (Landroidx/sqlite/db/SupportSQLiteOpenHelper;)Landroidx/sqlite/db/SupportSQLiteOpenHelper;
public fun getDatabaseName ()Ljava/lang/String;
Expand All @@ -23,7 +22,6 @@ public final class io/sentry/android/sqlite/SentrySupportSQLiteOpenHelper$Compan

public final class io/sentry/sqlite/SentrySQLiteDriver : androidx/sqlite/SQLiteDriver {
public static final field Companion Lio/sentry/sqlite/SentrySQLiteDriver$Companion;
public synthetic fun <init> (Landroidx/sqlite/SQLiteDriver;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
public static final fun create (Landroidx/sqlite/SQLiteDriver;)Landroidx/sqlite/SQLiteDriver;
public fun hasConnectionPool ()Z
public fun open (Ljava/lang/String;)Landroidx/sqlite/SQLiteConnection;
Expand Down
3 changes: 0 additions & 3 deletions sentry-android-sqlite/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import io.gitlab.arturbosch.detekt.Detekt
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion

plugins {
id("com.android.library")
Expand Down Expand Up @@ -36,8 +35,6 @@ android {

kotlin {
compilerOptions.jvmTarget = JvmTarget.JVM_11
compilerOptions.languageVersion = KotlinVersion.KOTLIN_1_9
compilerOptions.apiVersion = KotlinVersion.KOTLIN_1_9
}

testOptions {
Expand Down
3 changes: 0 additions & 3 deletions sentry-android-timber/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import io.gitlab.arturbosch.detekt.Detekt
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion

plugins {
id("com.android.library")
Expand Down Expand Up @@ -43,8 +42,6 @@ android {

kotlin {
compilerOptions.jvmTarget = JvmTarget.JVM_11
compilerOptions.languageVersion = KotlinVersion.KOTLIN_1_9
compilerOptions.apiVersion = KotlinVersion.KOTLIN_1_9
}

testOptions {
Expand Down
2 changes: 0 additions & 2 deletions sentry-apollo-3/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ plugins {

tasks.named<KotlinCompile>("compileKotlin") {
compilerOptions.jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_11
compilerOptions.languageVersion = org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_1_9
compilerOptions.apiVersion = org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_1_9
}

dependencies {
Expand Down
2 changes: 0 additions & 2 deletions sentry-apollo-4/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ plugins {

tasks.named<KotlinCompile>("compileKotlin") {
compilerOptions.jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_11
compilerOptions.languageVersion = org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_1_9
compilerOptions.apiVersion = org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_1_9
}

dependencies {
Expand Down
2 changes: 0 additions & 2 deletions sentry-apollo-5/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ plugins {

tasks.named<KotlinCompile>("compileKotlin") {
compilerOptions.jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_11
compilerOptions.languageVersion = org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_1_9
compilerOptions.apiVersion = org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_1_9
}

dependencies {
Expand Down
2 changes: 0 additions & 2 deletions sentry-apollo/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ plugins {

tasks.named<KotlinCompile>("compileKotlin") {
compilerOptions.jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_11
compilerOptions.languageVersion = org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_1_9
compilerOptions.apiVersion = org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_1_9
}

dependencies {
Expand Down
Loading
Loading