From c66bb2577d81f28d5b9e638800a2b1d6e56a39a6 Mon Sep 17 00:00:00 2001 From: JUUL Mobile Bot Date: Thu, 9 Jan 2025 10:07:25 -0800 Subject: [PATCH] Update Kotlin and KSP (#348) --- compile/src/main/kotlin/read/Parameters.kt | 3 ++- compile/src/test/kotlin/ExerciseProcessorTests.kt | 12 +++++++++--- gradle/libs.versions.toml | 6 +++--- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/compile/src/main/kotlin/read/Parameters.kt b/compile/src/main/kotlin/read/Parameters.kt index 998e99c..427d37d 100644 --- a/compile/src/main/kotlin/read/Parameters.kt +++ b/compile/src/main/kotlin/read/Parameters.kt @@ -40,7 +40,8 @@ internal fun KSAnnotation.toParameter(): Parameter = Parameter( name = getArgument(NAME) as String, nonNullTypeName = run { val targetClass = getArgument(TYPE) as KSType - val typeArguments = (getArgument(TYPE_ARGUMENTS) as List<*>) + val typeArguments = (getArgument(TYPE_ARGUMENTS) as List<*>?) + .orEmpty() .asSequence() .filterIsInstance() .map { it.asTypeName() } diff --git a/compile/src/test/kotlin/ExerciseProcessorTests.kt b/compile/src/test/kotlin/ExerciseProcessorTests.kt index 4f083c4..0d6e997 100644 --- a/compile/src/test/kotlin/ExerciseProcessorTests.kt +++ b/compile/src/test/kotlin/ExerciseProcessorTests.kt @@ -1,8 +1,11 @@ package com.juul.exercise.compile +import com.tschuchort.compiletesting.JvmCompilationResult import com.tschuchort.compiletesting.KotlinCompilation import com.tschuchort.compiletesting.SourceFile -import com.tschuchort.compiletesting.symbolProcessorProviders +import com.tschuchort.compiletesting.configureKsp +import com.tschuchort.compiletesting.kspLoggingLevels +import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity import org.jetbrains.kotlin.config.JvmTarget import org.junit.Rule import org.junit.rules.TemporaryFolder @@ -13,13 +16,16 @@ public abstract class ExerciseProcessorTests { @JvmField public val temporaryFolder: TemporaryFolder = TemporaryFolder() - protected fun compile(vararg files: SourceFile): Pair { + protected fun compile(vararg files: SourceFile): Pair { val compilation = KotlinCompilation().apply { workingDir = temporaryFolder.root jvmTarget = JvmTarget.JVM_1_8.description inheritClassPath = true sources = files.toList() - symbolProcessorProviders = listOf(ExerciseProcessorProvider()) + configureKsp(useKsp2 = true) { + symbolProcessorProviders += ExerciseProcessorProvider() + } + kspLoggingLevels = CompilerMessageSeverity.entries.toSet() } return compilation to compilation.compile() } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 5149cef..8ab0124 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -3,15 +3,15 @@ agp = "8.7.3" android-compile = "30" android-min = "21" jvm-toolchain = "11" -kotlin = "2.0.21" +kotlin = "2.1.0" [libraries] assertj = { module = "org.assertj:assertj-core", version = "3.27.1" } khronicle = { module = "com.juul.khronicle:khronicle-core", version = "0.5.0" } kotlin-parcelize-runtime = { module = "org.jetbrains.kotlin:kotlin-parcelize-runtime", version.ref = "kotlin" } kotlinpoet = { module = "com.squareup:kotlinpoet", version = "2.0.0" } -ksp-api = { module = "com.google.devtools.ksp:symbol-processing-api", version = "2.0.21-1.0.28" } -ksp-testing = { module = "com.github.tschuchortdev:kotlin-compile-testing-ksp", version = "1.6.0" } +ksp-api = { module = "com.google.devtools.ksp:symbol-processing-api", version = "2.1.0-1.0.29" } +ksp-testing = { module = "dev.zacsweers.kctfork:ksp", version = "0.7.0" } # https://github.com/ZacSweers/kotlin-compile-testing robolectric = { module = "org.robolectric:robolectric", version = "4.14.1" } [plugins]