Skip to content

Raise kotlin language version in plugin build. #931

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
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
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ plugins {
alias(libs.plugins.kotlinAndroid) apply false
alias(libs.plugins.kapt) apply false
alias(libs.plugins.ksp) apply false
alias(libs.plugins.compose.compiler) apply false
alias(libs.plugins.androidApplication) version BuildPluginsVersion.AGP apply false
alias(libs.plugins.androidLibrary) version BuildPluginsVersion.AGP apply false
alias(libs.plugins.spotless)
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/src/main/java/Dependencies.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ object BuildPluginsVersion {
}

object LibsVersion {
const val SDK_VERSION = 33
const val SDK_VERSION = 34
const val MIN_SDK_VERSION = 21
}

Expand Down
13 changes: 9 additions & 4 deletions examples/android-instrumentation-sample/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import org.jetbrains.kotlin.gradle.dsl.JvmTarget

plugins {
alias(libs.plugins.androidApplication) version BuildPluginsVersion.AGP
alias(libs.plugins.kotlinAndroid)
alias(libs.plugins.ksp)
id("io.sentry.android.gradle")
alias(libs.plugins.compose.compiler)
}

// useful for local debugging of the androidx.sqlite lib
Expand Down Expand Up @@ -49,10 +52,9 @@ android {
}

compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
kotlinOptions { jvmTarget = JavaVersion.VERSION_11.toString() }
namespace = "io.sentry.samples.instrumentation"

buildFeatures { compose = true }
Expand All @@ -62,7 +64,10 @@ android {
testOptions.unitTests.isIncludeAndroidResources = true
}

kotlin { jvmToolchain(11) }
kotlin {
jvmToolchain(17)
compilerOptions { jvmTarget.set(JvmTarget.JVM_17) }
}

// useful, when we want to modify room-generated classes, and then compile them into .class files
// so room does not re-generate and overwrite our changes
Expand Down
10 changes: 5 additions & 5 deletions examples/multi-module-sample/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.jetbrains.kotlin.gradle.dsl.JvmTarget

plugins {
alias(libs.plugins.kotlin)
id("io.sentry.jvm.gradle")
}

tasks.withType<KotlinCompile>().configureEach {
kotlinOptions {
freeCompilerArgs = listOf("-Xjsr305=strict")
jvmTarget = JavaVersion.VERSION_1_8.toString()
kotlin {
compilerOptions {
jvmTarget = JvmTarget.JVM_11
freeCompilerArgs.add("-Xjsr305=strict")
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import org.jetbrains.kotlin.config.KotlinCompilerVersion
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.jetbrains.kotlin.gradle.dsl.JvmTarget

plugins {
alias(libs.plugins.springBoot)
Expand Down Expand Up @@ -36,10 +36,10 @@ dependencies {

tasks.withType<Test>().configureEach { useJUnitPlatform() }

tasks.withType<KotlinCompile>().configureEach {
kotlinOptions {
freeCompilerArgs = listOf("-Xjsr305=strict")
jvmTarget = JavaVersion.VERSION_1_8.toString()
kotlin {
compilerOptions {
jvmTarget = JvmTarget.JVM_11
freeCompilerArgs.add("-Xjsr305=strict")
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import org.jetbrains.kotlin.config.KotlinCompilerVersion
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.jetbrains.kotlin.gradle.dsl.JvmTarget

plugins {
alias(libs.plugins.springBoot)
Expand Down Expand Up @@ -36,10 +36,10 @@ dependencies {

tasks.withType<Test>().configureEach { useJUnitPlatform() }

tasks.withType<KotlinCompile>().configureEach {
kotlinOptions {
freeCompilerArgs = listOf("-Xjsr305=strict")
jvmTarget = JavaVersion.VERSION_1_8.toString()
kotlin {
compilerOptions {
jvmTarget = JvmTarget.JVM_11
freeCompilerArgs.add("-Xjsr305=strict")
}
}

Expand Down
10 changes: 5 additions & 5 deletions examples/spring-boot-sample/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import org.jetbrains.kotlin.config.KotlinCompilerVersion
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.jetbrains.kotlin.gradle.dsl.JvmTarget

plugins {
alias(libs.plugins.springBoot)
Expand Down Expand Up @@ -36,10 +36,10 @@ dependencies {

tasks.withType<Test>().configureEach { useJUnitPlatform() }

tasks.withType<KotlinCompile>().configureEach {
kotlinOptions {
freeCompilerArgs = listOf("-Xjsr305=strict")
jvmTarget = JavaVersion.VERSION_1_8.toString()
kotlin {
compilerOptions {
jvmTarget = JvmTarget.JVM_11
freeCompilerArgs.add("-Xjsr305=strict")
}
}

Expand Down
11 changes: 6 additions & 5 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[versions]
kotlin = "1.8.20"
kotlin = "2.2.0"
agp = "8.10.1"

asm = "9.4" # // compatibility matrix -> https://developer.android.com/reference/tools/gradle-api/7.1/com/android/build/api/instrumentation/InstrumentationContext#apiversion
Expand All @@ -8,17 +8,18 @@ sqlite = "2.1.0"
sentry = "7.0.0"

sampleCoroutines = "1.5.2"
sampleRoom = "2.5.0"
sampleRoom = "2.7.2"
sampleRetrofit = "2.9.0"
sampleSpringBoot = "2.7.4"

[plugins]
kotlin = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
kotlinAndroid = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
kotlinSpring = { id = "org.jetbrains.kotlin.plugin.spring", version.ref = "kotlin" }
compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
kapt = { id = "org.jetbrains.kotlin.kapt", version.ref = "kotlin" }
ksp = { id = "com.google.devtools.ksp", version = "1.8.20-1.0.11" }
dokka = { id = "org.jetbrains.dokka", version = "1.8.10" }
ksp = { id = "com.google.devtools.ksp", version = "2.2.0-2.0.2" }
dokka = { id = "org.jetbrains.dokka", version = "1.9.20" }
spotless = { id = "com.diffplug.spotless", version = "7.0.4" }
groovyGradlePlugin = { id = "dev.gradleplugins.groovy-gradle-plugin", version = "1.7.1" }
mavenPublish = { id = "com.vanniktech.maven.publish", version = "0.27.0" }
Expand All @@ -42,7 +43,7 @@ kotlinCompilerEmbeddable = { group = "org.jetbrains.kotlin", name = "kotlin-comp
autoService = { group = "com.google.auto.service", name = "auto-service", version = "1.0.1" }
autoServiceAnnotatons = { group = "com.google.auto.service", name = "auto-service-annotations", version = "1.0.1" }
kotlinJunit = { group = "org.jetbrains.kotlin", name = "kotlin-test-junit", version.ref = "kotlin" }
kotlinCompileTesting = { group = "dev.zacsweers.kctfork", name = "core", version = "0.7.0" }
kotlinCompileTesting = { group = "dev.zacsweers.kctfork", name = "core", version = "0.7.1" }
truth = { module = "com.google.truth:truth", version = "1.4.4" }
composeDesktop = { group = "org.jetbrains.compose.desktop", name = "desktop", version = "1.6.10" }

Expand Down
14 changes: 9 additions & 5 deletions plugin-build/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import java.io.FileInputStream
import java.util.Properties
import org.gradle.api.tasks.testing.logging.TestLogEvent
import org.jetbrains.kotlin.config.KotlinCompilerVersion
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_1_8
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
Expand Down Expand Up @@ -86,12 +88,14 @@ tasks.withType<KotlinCompile>().configureEach {
if (!name.contains("agp", ignoreCase = true)) {
libraries.from.addAll(files(sourceSets["main"].groovy.classesDirectory))
}
}

kotlinOptions {
jvmTarget = JavaVersion.VERSION_11.toString()
freeCompilerArgs = listOf("-Xopt-in=kotlin.RequiresOptIn", "-Xjvm-default=enable")
languageVersion = "1.4"
apiVersion = "1.4"
kotlin {
compilerOptions {
jvmTarget.set(JvmTarget.JVM_11)
freeCompilerArgs.addAll("-Xopt-in=kotlin.RequiresOptIn", "-Xjvm-default=all")
apiVersion.set(KOTLIN_1_8)
languageVersion.set(KOTLIN_1_8)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import kotlin.test.assertTrue
import org.gradle.testkit.runner.TaskOutcome
import org.gradle.util.GradleVersion
import org.hamcrest.CoreMatchers.`is`
import org.jetbrains.kotlin.gradle.report.TaskExecutionState.UP_TO_DATE
import org.junit.Assume.assumeThat
import org.junit.Test

Expand Down
Loading
Loading