Skip to content

Commit 2f90484

Browse files
authored
Add support for Kotlin 2.1.20 (#871)
* Bump to Gradle 7.6.4, bump compiler plugin to Kotlin 2.1.20 * Fix missing named argument * Fix Kotlin 2.1.20 incompatibility * Update Changelog * Compile the whole extension against specific Kotlin versions * Update logic for determining Kotlin version * Gradle 7.6.4 everywhere * Update min Gradle version for test matrix * Switch to dev.zacsweers.kctfor for Kotlin 2.x * Target Java 11 * Set JVM toolchain to 11 to fix kapt issues * Drop AGP 7.2.1 from test matrix * Trigger Build
1 parent e2c08b8 commit 2f90484

12 files changed

Lines changed: 347 additions & 27 deletions

File tree

.github/workflows/test-matrix-agp-gradle.yaml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,13 @@ jobs:
1616
strategy:
1717
fail-fast: false
1818
matrix:
19-
agp: [ "7.2.1" ]
20-
gradle: [ "7.4" ]
19+
agp: [ "7.3.0" ]
20+
gradle: [ "7.6.4" ]
2121
java: [ "11" ]
2222
groovy: [ "1.2" ]
2323
include:
24-
- agp: "7.3.0"
25-
gradle: "7.5"
26-
java: "11"
27-
groovy: "1.2"
2824
- agp: "7.4.0"
29-
gradle: "7.6"
25+
gradle: "7.6.4"
3026
java: "11"
3127
groovy: "1.2"
3228
- agp: "8.0.0"

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## Unreleased
44

5+
### Fixes
6+
7+
- Fix another API incompatibility with Kotlin 2.1.20 ([#871](https://github.com/getsentry/sentry-android-gradle-plugin/pull/871))
8+
59
### Dependencies
610

711
- Bump CLI from v2.43.0 to v2.43.1 ([#872](https://github.com/getsentry/sentry-android-gradle-plugin/pull/872))

gradle/libs.versions.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@ proguard = { group = "com.guardsquare", name = "proguard-gradle", version = "7.1
3636
# this allows us to develop against a fixed version of Gradle, as opposed to depending on the
3737
# locally available version. kotlin-gradle-plugin follows the same approach.
3838
# More info: https://docs.nokee.dev/manual/gradle-plugin-development-plugin.html
39-
gradleApi = { group = "dev.gradleplugins", name = "gradle-api", version = "7.6" }
39+
gradleApi = { group = "dev.gradleplugins", name = "gradle-api", version = "7.6.4" }
4040
agp = { group = "com.android.tools.build", name = "gradle", version.ref = "agp" }
4141
kotlinCompilerEmbeddable = { group = "org.jetbrains.kotlin", name = "kotlin-compiler-embeddable" }
4242
autoService = { group = "com.google.auto.service", name = "auto-service", version = "1.0.1" }
4343
autoServiceAnnotatons = { group = "com.google.auto.service", name = "auto-service-annotations", version = "1.0.1" }
4444
kotlinJunit = { group = "org.jetbrains.kotlin", name = "kotlin-test-junit", version.ref = "kotlin" }
45-
kotlinCompileTesting = { group = "com.github.tschuchortdev", name = "kotlin-compile-testing", version = "1.6.0" }
45+
kotlinCompileTesting = { group = "dev.zacsweers.kctfork", name = "core", version = "0.7.0" }
4646
composeDesktop = { group = "org.jetbrains.compose.desktop", name = "desktop", version = "1.6.10" }
4747

4848
# bytecode instrumentation
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-all.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.4-all.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

plugin-build/buildSrc/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ sourceSets {
1818
// we cannot use the version from Dependencies.kt because it's not available at this moment, the
1919
// proper way to share the dependency notation is to use libs.versions.toml, but that's for later
2020
dependencies {
21-
compileOnly("dev.gradleplugins:gradle-api:7.6")
21+
compileOnly("dev.gradleplugins:gradle-api:7.6.4")
2222
}
2323

2424
gradlePlugin {

sentry-kotlin-compiler-plugin/build.gradle.kts

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
1+
import org.gradle.kotlin.dsl.withType
2+
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
3+
14
plugins {
2-
alias(libs.plugins.kotlin) version "1.9.24"
3-
alias(libs.plugins.kapt) version "1.9.24"
5+
alias(libs.plugins.kotlin) version "2.1.0"
6+
alias(libs.plugins.kapt) version "2.1.0"
47
id("distribution")
58
alias(libs.plugins.mavenPublish)
69
alias(libs.plugins.spotless)
710
}
811

12+
val kotlin1920: SourceSet by sourceSets.creating
13+
val kotlin2120: SourceSet by sourceSets.creating
14+
915
allprojects {
1016
repositories {
1117
google()
@@ -62,6 +68,14 @@ dependencies {
6268
testImplementation(libs.kotlinCompilerEmbeddable)
6369
testImplementation(libs.kotlinCompileTesting)
6470
testImplementation(libs.composeDesktop)
71+
testImplementation(kotlin1920.output)
72+
testImplementation(kotlin2120.output)
73+
74+
kotlin1920.compileOnlyConfigurationName("org.jetbrains.kotlin:kotlin-compiler-embeddable:1.9.24")
75+
kotlin2120.compileOnlyConfigurationName("org.jetbrains.kotlin:kotlin-compiler-embeddable:2.1.20")
76+
77+
compileOnly(kotlin1920.output)
78+
compileOnly(kotlin2120.output)
6579
}
6680

6781
kapt { correctErrorTypes = true }
@@ -76,3 +90,20 @@ plugins.withId("com.vanniktech.maven.publish.base") {
7690
}
7791
}
7892
}
93+
94+
tasks.withType<Jar> {
95+
from(kotlin1920.output)
96+
from(kotlin2120.output)
97+
}
98+
99+
// see
100+
// https://youtrack.jetbrains.com/issue/KTIJ-24311/task-current-target-is-17-and-kaptGenerateStubsProductionDebugKotlin-task-current-target-is-1.8-jvm-target-compatibility-should
101+
kotlin { jvmToolchain(11) }
102+
103+
tasks.withType<KotlinCompile>().configureEach {
104+
kotlinOptions {
105+
jvmTarget = JavaVersion.VERSION_11.toString()
106+
languageVersion = "1.9"
107+
apiVersion = "1.9"
108+
}
109+
}

sentry-kotlin-compiler-plugin/gradle.properties

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,3 @@ POM_LICENCE_URL=https://github.com/getsentry/sentry-android-gradle-plugin/blob/m
1616
POM_DEVELOPER_ID=getsentry
1717
POM_DEVELOPER_NAME=Sentry Team and Contributors
1818
POM_DEVELOPER_URL=https://github.com/getsentry/
19-
20-
kotlin.experimental.tryK2=true
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-all.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.4-all.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

sentry-kotlin-compiler-plugin/src/main/kotlin/io/sentry/compose/JetpackComposeTracingIrExtension.kt renamed to sentry-kotlin-compiler-plugin/src/kotlin1920/kotlin/io/sentry/compose/JetpackComposeTracingIrExtension19.kt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,12 @@ import org.jetbrains.kotlin.ir.util.kotlinFqName
2424
import org.jetbrains.kotlin.name.CallableId
2525
import org.jetbrains.kotlin.name.ClassId
2626
import org.jetbrains.kotlin.name.FqName
27+
import org.jetbrains.kotlin.name.Name
2728
import org.jetbrains.kotlin.name.SpecialNames
2829

2930
// required only for Kotlin 2.0.0
3031
// @UnsafeDuringIrConstructionAPI
31-
class JetpackComposeTracingIrExtension(private val messageCollector: MessageCollector) :
32+
class JetpackComposeTracingIrExtension19(private val messageCollector: MessageCollector) :
3233
IrGenerationExtension {
3334

3435
override fun generate(moduleFragment: IrModuleFragment, pluginContext: IrPluginContext) {
@@ -213,7 +214,7 @@ class JetpackComposeTracingIrExtension(private val messageCollector: MessageColl
213214
val sentryTagCall = generateSentryTagCall(builder, composableName)
214215

215216
// Modifier.then()
216-
val thenCall = builder.irCall(modifierThen, modifierType)
217+
val thenCall = builder.irCall(modifierThen, type = modifierType)
217218
thenCall.putValueArgument(0, expression)
218219
thenCall.dispatchReceiver = sentryTagCall
219220

@@ -226,7 +227,7 @@ class JetpackComposeTracingIrExtension(private val messageCollector: MessageColl
226227
composableName: String,
227228
): IrCall {
228229
val sentryTagCall =
229-
builder.irCall(sentryModifierTagFunctionRef, modifierType).also {
230+
builder.irCall(sentryModifierTagFunctionRef, type = modifierType).also {
230231
it.extensionReceiver =
231232
builder.irGetObjectValue(
232233
type = modifierCompanionClassRef.createType(false, emptyList()),
@@ -243,9 +244,9 @@ class JetpackComposeTracingIrExtension(private val messageCollector: MessageColl
243244
}
244245

245246
fun FqName.classId(name: String): ClassId {
246-
return ClassId(this, org.jetbrains.kotlin.name.Name.identifier(name))
247+
return ClassId(this, Name.identifier(name))
247248
}
248249

249250
fun ClassId.callableId(name: String): CallableId {
250-
return CallableId(this, org.jetbrains.kotlin.name.Name.identifier(name))
251+
return CallableId(this, Name.identifier(name))
251252
}

0 commit comments

Comments
 (0)