Skip to content
This repository was archived by the owner on Dec 17, 2025. It is now read-only.

Commit f906a03

Browse files
authored
Update Kotlin to v2.1.10, Gradle to v8.13, update various other dependencies, adapt LensesProcessorTests (#938)
* Update Gradle to version 8.13 * Update project and dependencies to Kotlin 2.1.10 * Adapt LensesProcessorTests so that they wor kwith the forked testing lib * Fix remaining compile tests by adapting them to the updated Kotlin 2.1 behavior * Fix npm compatibility issues * Remove unused dependencies from versions.properties * Update more dependencies * Use JDK 21 for lenses compile tests
1 parent 40f67d1 commit f906a03

File tree

9 files changed

+526
-459
lines changed

9 files changed

+526
-459
lines changed

build.gradle.kts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsPlugin
2+
import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsPlugin.Companion.kotlinNodeJsEnvSpec
3+
14
plugins {
25
kotlin("multiplatform") apply false
36
kotlin("plugin.serialization") apply false
@@ -13,6 +16,18 @@ allprojects {
1316
repositories {
1417
mavenCentral()
1518
}
19+
20+
// We use a fixed NodeJS LTS version since there are NPM dependencies that are not yet
21+
// compatible with newer node versions. In our case, this is cliui.
22+
// Have a look at https://nodejs.org/en/about/previous-releases for the available node
23+
// versions.
24+
// NodeJS v20 is supported until April 2026.
25+
plugins.withType<NodeJsPlugin> {
26+
kotlinNodeJsEnvSpec.apply {
27+
version = "20.19.4"
28+
download = true
29+
}
30+
}
1631
}
1732

1833
subprojects {

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

headless-demo/build.gradle.kts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
import com.google.devtools.ksp.gradle.KspTask
21
import com.google.devtools.ksp.gradle.KspTaskMetadata
3-
import org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask
42

53
plugins {
64
kotlin("multiplatform")
@@ -9,6 +7,7 @@ plugins {
97

108
kotlin {
119
jvm() // needed for kspCommonMainMetadata
10+
1211
js(IR) {
1312
browser()
1413
}.binaries.executable()

headless-demo/src/jsMain/kotlin/dev/fritz2/headlessdemo/App.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ fun RenderContext.overview() {
130130
}
131131
}
132132
}
133-
134133
}
135134

136135
fun main() {

kotlin-js-store/yarn.lock

Lines changed: 431 additions & 375 deletions
Large diffs are not rendered by default.

lenses-annotation-processor/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ kotlin {
3737
implementation(Kotlin.test.junit5)
3838
implementation(Testing.junit.jupiter.params)
3939
implementation(Testing.assertj.core)
40-
implementation("com.github.tschuchortdev:kotlin-compile-testing:_")
41-
implementation("com.github.tschuchortdev:kotlin-compile-testing-ksp:_")
40+
implementation("dev.zacsweers.kctfork:core:_")
41+
implementation("dev.zacsweers.kctfork:ksp:_")
4242
}
4343
}
4444
}

lenses-annotation-processor/src/jvmTest/kotlin/dev/fritz2/lens/LensesProcessorTests.kt

Lines changed: 54 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package dev.fritz2.lens
22

3-
import com.tschuchort.compiletesting.KotlinCompilation
4-
import com.tschuchort.compiletesting.SourceFile
5-
import com.tschuchort.compiletesting.symbolProcessorProviders
3+
import com.tschuchort.compiletesting.*
64
import org.assertj.core.api.Assertions.assertThat
75
import org.jetbrains.kotlin.compiler.plugin.ExperimentalCompilerApi
86
import org.junit.jupiter.api.DisplayName
@@ -22,22 +20,21 @@ class LensesProcessorTests {
2220

2321
@ExperimentalPathApi
2422
private fun compileSource(vararg source: SourceFile) = KotlinCompilation().apply {
25-
sources = source.toList()
26-
symbolProcessorProviders = listOf(LensesProcessorProvider())
27-
workingDir = createTempDirectory("fritz2-tests").toFile()
28-
inheritClassPath = true
29-
verbose = false
23+
configureKsp(useKsp2 = true) {
24+
jvmTarget = "21"
25+
languageVersion = "2.1"
26+
sources = source.toList()
27+
symbolProcessorProviders += LensesProcessorProvider()
28+
workingDir = createTempDirectory("fritz2-tests").toFile()
29+
inheritClassPath = true
30+
verbose = false
31+
}
3032
}.compile()
3133

32-
// workaround copied by https://github.com/tschuchortdev/kotlin-compile-testing/issues/129#issuecomment-804390310
33-
internal val KotlinCompilation.Result.workingDir: File
34-
get() =
35-
outputDirectory.parentFile!!
36-
3734
// workaround inspired by https://github.com/tschuchortdev/kotlin-compile-testing/issues/129#issuecomment-804390310
38-
val KotlinCompilation.Result.kspGeneratedSources: List<File>
35+
private val CompilationResult.kspGeneratedSources: List<File>
3936
get() {
40-
val kspWorkingDir = workingDir.resolve("ksp")
37+
val kspWorkingDir = outputDirectory.parentFile!!.resolve("ksp")
4138
val kspGeneratedDir = kspWorkingDir.resolve("sources")
4239
val kotlinGeneratedDir = kspGeneratedDir.resolve("kotlin")
4340
val javaGeneratedDir = kspGeneratedDir.resolve("java")
@@ -81,13 +78,13 @@ class LensesProcessorTests {
8178
// lenses will appear in `BarLenses.kt`
8279
@Lenses
8380
sealed class Bar {
84-
val bar: Int
81+
abstract val bar: Int
8582
companion object
8683
}
8784
8885
data class BarImpl(
8986
override val bar: Int,
90-
) : Bar
87+
) : Bar()
9188
"""
9289
)
9390

@@ -224,7 +221,7 @@ class LensesProcessorTests {
224221
import dev.fritz2.core.Lenses
225222
226223
@Lenses
227-
data class Foo(private val foo: Int, param: String) { // no public property defined in ctor!
224+
data class Foo(private val foo: Int) { // no public property defined in ctor!
228225
companion object
229226
val someNoneCtorProp: Int = foo + 1
230227
}
@@ -355,7 +352,7 @@ class LensesProcessorTests {
355352
// private field -> no lens possible!
356353
companion object {
357354
// should not disturb
358-
fun toJson(foo: Foo) = Json.decodeFromString(serializer(), foo)
355+
fun displayValue(foo: Foo) = foo.toString()
359356
}
360357
val ignored = bar + 1 // must not appear in lens!
361358
val ignoredDelegated by lazy { bar + 1 } // must not appear in lens!
@@ -635,8 +632,7 @@ class LensesProcessorTests {
635632
| }
636633
|)
637634
|
638-
|public fun <PARENT> Lens<PARENT, Framework>.fooBar(): Lens<PARENT, MyType> = this +
639-
| Framework.fooBar()
635+
|public fun <PARENT> Lens<PARENT, Framework>.fooBar(): Lens<PARENT, MyType> = this + Framework.fooBar()
640636
|
641637
|public fun Framework.Companion.baz(): Lens<Framework, MyGenericType<Int>> = lensOf(
642638
| "baz",
@@ -654,14 +650,11 @@ class LensesProcessorTests {
654650
| }
655651
|)
656652
|
657-
|public fun <PARENT> Lens<PARENT, Framework>.baz(): Lens<PARENT, MyGenericType<Int>> = this +
658-
| Framework.baz()
653+
|public fun <PARENT> Lens<PARENT, Framework>.baz(): Lens<PARENT, MyGenericType<Int>> = this + Framework.baz()
659654
|
660-
|public fun Framework.Companion.fritz2(): Lens<Framework, Fritz2> =
661-
| lensForUpcasting<Framework,Fritz2>()
655+
|public fun Framework.Companion.fritz2(): Lens<Framework, Fritz2> = lensForUpcasting<Framework,Fritz2>()
662656
|
663-
|public fun Framework.Companion.spring(): Lens<Framework, Spring> =
664-
| lensForUpcasting<Framework,Spring>()
657+
|public fun Framework.Companion.spring(): Lens<Framework, Spring> = lensForUpcasting<Framework,Spring>()
665658
""".trimMargin()
666659

667660
@JvmStatic
@@ -720,17 +713,15 @@ class LensesProcessorTests {
720713
| { p, v -> p.copy(fooBar = v)}
721714
| )
722715
|
723-
|public fun <PARENT> Lens<PARENT, Framework>.fooBar(): Lens<PARENT, MyType> = this +
724-
| Framework.fooBar()
716+
|public fun <PARENT> Lens<PARENT, Framework>.fooBar(): Lens<PARENT, MyType> = this + Framework.fooBar()
725717
|
726718
|public fun Framework.Companion.baz(): Lens<Framework, MyGenericType<Int>> = lensOf(
727719
| "baz",
728720
| { it.baz },
729721
| { p, v -> p.copy(baz = v)}
730722
| )
731723
|
732-
|public fun <PARENT> Lens<PARENT, Framework>.baz(): Lens<PARENT, MyGenericType<Int>> = this +
733-
| Framework.baz()
724+
|public fun <PARENT> Lens<PARENT, Framework>.baz(): Lens<PARENT, MyGenericType<Int>> = this + Framework.baz()
734725
""".trimMargin()
735726
),
736727
arguments(
@@ -744,25 +735,24 @@ class LensesProcessorTests {
744735
745736
class MyType
746737
class MyGenericType<T>
747-
738+
748739
@Lenses
749-
sealed class Framework(
750-
val bar: Int,
751-
val foo: String
752-
) {
740+
sealed class Framework {
741+
abstract val bar: Int
742+
abstract val foo: String
753743
abstract val fooBar: MyType
754744
abstract val baz: MyGenericType<Int>
755745
companion object
756746
}
757-
747+
758748
data class Fritz2 (
759749
override val bar: Int,
760750
override val foo: String,
761751
override val fooBar: MyType,
762752
override val baz: MyGenericType<Int>,
763753
val usesFlows: Boolean,
764754
) : Framework()
765-
755+
766756
data class Spring (
767757
override val bar: Int,
768758
override val foo: String,
@@ -963,6 +953,7 @@ class LensesProcessorTests {
963953
package dev.fritz2.lenstest
964954
965955
import dev.fritz2.core.Lenses
956+
import dev.fritz2.core.NoLens
966957
967958
@Lenses
968959
sealed class Foo(
@@ -971,11 +962,14 @@ class LensesProcessorTests {
971962
) {
972963
companion object
973964
}
974-
975-
@Lens
965+
966+
@Lenses
976967
data class FooImpl (
977968
val something: String
978-
) : Foo {
969+
) : Foo(
970+
alsoIgnored = "ignored",
971+
ignored = 42
972+
) {
979973
companion object
980974
}
981975
"""
@@ -998,19 +992,19 @@ class LensesProcessorTests {
998992
package dev.fritz2.lenstest
999993
1000994
import dev.fritz2.core.Lenses
995+
import dev.fritz2.core.NoLens
1001996
1002997
@Lenses
1003998
sealed interface Foo {
1004-
protected val ignored: Int
1005-
1006999
@NoLens
1007-
val alsoIgnored: String
1008-
1000+
val ignored: Int
1001+
10091002
companion object
10101003
}
1011-
1012-
@Lens
1004+
1005+
@Lenses
10131006
data class FooImpl (
1007+
override val ignored: Int,
10141008
val something: String
10151009
) : Foo {
10161010
companion object
@@ -1361,11 +1355,9 @@ class LensesProcessorTests {
13611355
|
13621356
|public fun <PARENT> Lens<PARENT, Framework>.foo(): Lens<PARENT, String> = this + Framework.foo()
13631357
|
1364-
|public fun Framework.Companion.fritz2(): Lens<Framework, Fritz2> =
1365-
| lensForUpcasting<Framework,Fritz2>()
1358+
|public fun Framework.Companion.fritz2(): Lens<Framework, Fritz2> = lensForUpcasting<Framework,Fritz2>()
13661359
|
1367-
|public fun Framework.Companion.spring(): Lens<Framework, Spring> =
1368-
| lensForUpcasting<Framework,Spring>()
1360+
|public fun Framework.Companion.spring(): Lens<Framework, Spring> = lensForUpcasting<Framework,Spring>()
13691361
""".trimMargin()
13701362

13711363

@@ -1379,28 +1371,31 @@ class LensesProcessorTests {
13791371
package dev.fritz2.lenstest
13801372
13811373
import dev.fritz2.core.Lenses
1374+
import dev.fritz2.core.NoLens
13821375
13831376
@Lenses
13841377
sealed class Framework(
13851378
@NoLens val ignore: String
13861379
) {
13871380
@NoLens
1388-
val alsoIgnore: String
1381+
abstract val alsoIgnore: String
13891382
abstract val foo: String
13901383
companion object
13911384
}
1392-
1385+
13931386
data class Fritz2 (
13941387
override val foo: String,
1395-
) : Framework {
1396-
override val ignore: String = "Fritz2"
1388+
) : Framework(
1389+
ignore = "Fritz2"
1390+
) {
13971391
override val alsoIgnore: String = "Fritz2"
13981392
}
1399-
1393+
14001394
data class Spring (
14011395
override val foo: String,
1402-
) : Framework {
1403-
override val ignore: String = "Spring"
1396+
) : Framework(
1397+
ignore = "Spring"
1398+
) {
14041399
override val alsoIgnore: String = "Fritz2"
14051400
}
14061401
"""
@@ -1415,6 +1410,7 @@ class LensesProcessorTests {
14151410
package dev.fritz2.lenstest
14161411
14171412
import dev.fritz2.core.Lenses
1413+
import dev.fritz2.core.NoLens
14181414
14191415
@Lenses
14201416
sealed interface Framework {

test-server/src/main/kotlin/dev/fritz2/Server.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,14 @@ import io.ktor.server.auth.*
1010
import io.ktor.server.engine.*
1111
import io.ktor.server.netty.*
1212
import io.ktor.server.plugins.*
13-
import io.ktor.server.plugins.callloging.*
13+
import io.ktor.server.plugins.calllogging.CallLogging
1414
import io.ktor.server.plugins.contentnegotiation.*
1515
import io.ktor.server.request.*
1616
import io.ktor.server.response.*
1717
import io.ktor.server.routing.*
1818
import io.ktor.server.websocket.*
1919
import io.ktor.util.*
20+
import io.ktor.utils.io.toByteArray
2021
import io.ktor.websocket.*
2122
import kotlinx.coroutines.Dispatchers
2223
import kotlinx.coroutines.channels.ClosedReceiveChannelException

0 commit comments

Comments
 (0)