Skip to content
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

Update to Kotlin 2.1.0 #1677

Merged
merged 17 commits into from
Jan 2, 2025
Merged
21 changes: 11 additions & 10 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ plugins {
alias(libs.plugins.mavenPublish) apply false
alias(libs.plugins.dokka)
alias(libs.plugins.ksp) apply false
alias(libs.plugins.versionsPlugin)
alias(libs.plugins.dependencyGuard) apply false
alias(libs.plugins.compose) apply false
alias(libs.plugins.kotlin.plugin.compose) apply false
Expand Down Expand Up @@ -169,15 +168,21 @@ subprojects {
}

val hasCompose = !project.hasProperty("circuit.noCompose")
val useK2Kapt =
providers.gradleProperty("kapt.use.k2").map { it.toBooleanStrict() }.getOrElse(false)
plugins.withType<KotlinBasePlugin> {
tasks.withType<KotlinCompilationTask<*>>().configureEach {
// Don't double apply to stub gen
if (this is KaptGenerateStubsTask) {
// TODO due to Anvil we need to force language version 1.9
compilerOptions {
progressiveMode.set(false)
languageVersion.set(KotlinVersion.KOTLIN_1_9)
if (useK2Kapt) {
// K2 Kapt is in alpha
compilerOptions.allWarningsAsErrors.set(false)
} else {
compilerOptions {
progressiveMode.set(false)
languageVersion.set(KotlinVersion.KOTLIN_1_9)
}
}
// Don't double apply to stub gen
return@configureEach
}
val isWasmTask = name.contains("wasm", ignoreCase = true)
Expand Down Expand Up @@ -256,10 +261,6 @@ subprojects {
module("com.google.guava:listenablefuture") { replacedBy("com.google.guava:guava") }
}

pluginManager.withPlugin("org.jetbrains.kotlin.kapt") {
tasks.withType<KaptGenerateStubsTask>().configureEach { useK2Kapt.set(true) }
}

pluginManager.withPlugin("com.vanniktech.maven.publish") {
apply(plugin = "org.jetbrains.dokka")

Expand Down
1 change: 0 additions & 1 deletion circuit-foundation/api/android/circuit-foundation.api
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ public final class com/slack/circuit/foundation/CircuitKt {

public final class com/slack/circuit/foundation/ComposableSingletons$CircuitKt {
public static final field INSTANCE Lcom/slack/circuit/foundation/ComposableSingletons$CircuitKt;
public static field lambda-1 Lkotlin/jvm/functions/Function4;
public fun <init> ()V
public final fun getLambda-1$circuit_foundation_release ()Lkotlin/jvm/functions/Function4;
}
Expand Down
1 change: 0 additions & 1 deletion circuit-foundation/api/jvm/circuit-foundation.api
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ public final class com/slack/circuit/foundation/CircuitKt {

public final class com/slack/circuit/foundation/ComposableSingletons$CircuitKt {
public static final field INSTANCE Lcom/slack/circuit/foundation/ComposableSingletons$CircuitKt;
public static field lambda-1 Lkotlin/jvm/functions/Function4;
public fun <init> ()V
public final fun getLambda-1$circuit_foundation ()Lkotlin/jvm/functions/Function4;
}
Expand Down
1 change: 0 additions & 1 deletion circuit-overlay/api/android/circuit-overlay.api
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ public abstract class com/slack/circuit/overlay/AnimatedOverlay : com/slack/circ

public final class com/slack/circuit/overlay/ComposableSingletons$ContentWithOverlaysKt {
public static final field INSTANCE Lcom/slack/circuit/overlay/ComposableSingletons$ContentWithOverlaysKt;
public static field lambda-1 Lkotlin/jvm/functions/Function4;
public fun <init> ()V
public final fun getLambda-1$circuit_overlay_release ()Lkotlin/jvm/functions/Function4;
}
Expand Down
1 change: 0 additions & 1 deletion circuit-overlay/api/jvm/circuit-overlay.api
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ public abstract class com/slack/circuit/overlay/AnimatedOverlay : com/slack/circ

public final class com/slack/circuit/overlay/ComposableSingletons$ContentWithOverlaysKt {
public static final field INSTANCE Lcom/slack/circuit/overlay/ComposableSingletons$ContentWithOverlaysKt;
public static field lambda-1 Lkotlin/jvm/functions/Function4;
public fun <init> ()V
public final fun getLambda-1$circuit_overlay ()Lkotlin/jvm/functions/Function4;
}
Expand Down
1 change: 0 additions & 1 deletion circuitx/overlays/api/android/overlays.api
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ public final class com/slack/circuitx/overlays/BottomSheetOverlay : com/slack/ci

public final class com/slack/circuitx/overlays/ComposableSingletons$BottomSheetOverlayKt {
public static final field INSTANCE Lcom/slack/circuitx/overlays/ComposableSingletons$BottomSheetOverlayKt;
public static field lambda-1 Lkotlin/jvm/functions/Function2;
public fun <init> ()V
public final fun getLambda-1$overlays_release ()Lkotlin/jvm/functions/Function2;
}
Expand Down
1 change: 0 additions & 1 deletion circuitx/overlays/api/jvm/overlays.api
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ public final class com/slack/circuitx/overlays/BottomSheetOverlay : com/slack/ci

public final class com/slack/circuitx/overlays/ComposableSingletons$BottomSheetOverlayKt {
public static final field INSTANCE Lcom/slack/circuitx/overlays/ComposableSingletons$BottomSheetOverlayKt;
public static field lambda-1 Lkotlin/jvm/functions/Function2;
public fun <init> ()V
public final fun getLambda-1$overlays ()Lkotlin/jvm/functions/Function2;
}
Expand Down
9 changes: 3 additions & 6 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,14 @@ android.suppressUnsupportedOptionWarnings=android.suppressUnsupportedOptionWarni
android.lint.useK2Uast

android.lint.useK2Uast=true
# TODO blocked on https://github.com/google/ksp/issues/2091
ksp.useKSP2=false
ksp.useKSP2=true

# SKIE sets max versions, so we leave this in (even if commented out) for ease of use with new
# Kotlin versions
skie.kgpVersion=2.0.20
#skie.kgpVersion=2.1.0

# Use Kapt4 in K2
# TODO doesn't work with Anvil yet
kapt.use.k2=false
kapt.use.k2=true

org.gradle.parallel=true
org.gradle.configureondemand=true
Expand All @@ -52,7 +50,6 @@ dependency.analysis.compatibility=NONE
# Disable noisy stability warning
kotlin.mpp.stability.nowarn=true
kotlin.mpp.androidSourceSetLayoutVersion=2
kotlin.mpp.androidGradlePluginCompatibility.nowarn=true
# Ignore disabled targets (i.e iOS on Linux)
kotlin.native.ignoreDisabledTargets=true
kotlin.apple.xcodeCompatibility.nowarn=true
Expand Down
8 changes: 3 additions & 5 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ jdk = "22"
jvmTarget = "11"
publishedJvmTarget = "1.8"
kct = "0.7.0"
kotlin = "2.0.21"
kotlin = "2.1.0"
kotlinInject = "0.7.2"
kotlinInject-anvil = "0.1.1"
kotlinpoet = "2.0.0"
kotlinx-coroutines = "1.9.0"
kotlinx-serialization = "1.7.3"
ksp = "2.0.21-1.0.28"
ksp = "2.1.0-1.0.29"
ktfmt = "0.53"
ktor = "3.0.3"
leakcanary = "2.14"
Expand All @@ -49,12 +49,11 @@ picnic = "0.7.0"
robolectric = "4.14.1"
roborazzi = "1.37.0"
skie = "0.10.0"
spotless = "7.0.0.BETA2"
spotless = "7.0.0.BETA4"
sqldelight = "2.0.2"
telephoto = "0.14.0"
testParameterInjector = "1.18"
turbine = "1.2.0"
versionsPlugin = "0.49.0"

[plugins]
agp-application = { id = "com.android.application", version.ref = "agp" }
Expand Down Expand Up @@ -83,7 +82,6 @@ roborazzi = { id = "io.github.takahirom.roborazzi", version.ref = "roborazzi" }
skie = { id = "co.touchlab.skie", version.ref = "skie" }
spotless = { id = "com.diffplug.spotless", version.ref = "spotless" }
sqldelight = { id = "app.cash.sqldelight", version.ref = "sqldelight" }
versionsPlugin = { id = "com.github.ben-manes.versions", version.ref = "versionsPlugin" }

[libraries]
agp = { module = "com.android.tools.build:gradle", version.ref = "agp" }
Expand Down
59 changes: 22 additions & 37 deletions kotlin-js-store/yarn.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions samples/counter/apps/gradle.properties

This file was deleted.

2 changes: 1 addition & 1 deletion samples/counter/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# https://kotlinlang.org/docs/native-ios-integration.html#calling-kotlin-suspending-functions
kotlin.native.binary.objcExportSuspendFunctionLaunchThreadRestriction=none
kotlin.native.binary.objcExportSuspendFunctionLaunchThreadRestriction=none
6 changes: 6 additions & 0 deletions samples/kotlin-inject/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Copyright (C) 2024 Slack Technologies, LLC
// SPDX-License-Identifier: Apache-2.0
import com.google.devtools.ksp.KspExperimental

plugins {
alias(libs.plugins.kotlin.jvm)
alias(libs.plugins.ksp)
Expand All @@ -9,6 +11,10 @@ plugins {
ksp {
arg("circuit.codegen.lenient", "true")
arg("circuit.codegen.mode", "kotlin_inject_anvil")
@OptIn(KspExperimental::class)
// kotlin-inject cannot see through typealiases in KSP2
// https://github.com/evant/kotlin-inject/issues/458
useKsp2.set(false)
}

dependencies {
Expand Down
10 changes: 1 addition & 9 deletions samples/star/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// SPDX-License-Identifier: Apache-2.0
import com.android.build.api.dsl.LibraryExtension
import com.google.devtools.ksp.gradle.KspAATask
import com.google.devtools.ksp.gradle.KspTaskJvm
import java.util.Locale
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
Expand Down Expand Up @@ -283,15 +282,8 @@ afterEvaluate {
if (target != "Android" && target != "Jvm") continue
val buildType = if (target == "Android") "Release" else ""
val kspTaskName = "ksp${buildType}Kotlin${target}"
val useKSP2 = providers.gradleProperty("ksp.useKSP2").getOrElse("false").toBoolean()
val generatedKspKotlinFiles =
if (useKSP2) {
val kspReleaseTask = tasks.named<KspAATask>(kspTaskName)
kspReleaseTask.flatMap { it.kspConfig.kotlinOutputDir }
} else {
val kspReleaseTask = tasks.named<KspTaskJvm>(kspTaskName)
kspReleaseTask.flatMap { it.destination }
}
tasks.named<KspAATask>(kspTaskName).flatMap { it.kspConfig.kotlinOutputDir }
tasks.named<KotlinCompile>("kaptGenerateStubs${buildType}Kotlin${target}").configure {
source(generatedKspKotlinFiles)
}
Expand Down
Loading