Skip to content

Commit

Permalink
Update Kotlin and KSP (#348)
Browse files Browse the repository at this point in the history
  • Loading branch information
juul-mobile-bot authored Jan 9, 2025
1 parent 035f60a commit c66bb25
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
3 changes: 2 additions & 1 deletion compile/src/main/kotlin/read/Parameters.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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<KSType>()
.map { it.asTypeName() }
Expand Down
12 changes: 9 additions & 3 deletions compile/src/test/kotlin/ExerciseProcessorTests.kt
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -13,13 +16,16 @@ public abstract class ExerciseProcessorTests {
@JvmField
public val temporaryFolder: TemporaryFolder = TemporaryFolder()

protected fun compile(vararg files: SourceFile): Pair<KotlinCompilation, KotlinCompilation.Result> {
protected fun compile(vararg files: SourceFile): Pair<KotlinCompilation, JvmCompilationResult> {
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()
}
Expand Down
6 changes: 3 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit c66bb25

Please sign in to comment.