What is a working configuration to auto-generate L...
# arrow
d
What is a working configuration to auto-generate Lenses when using Arrow's optics? I followed the guide on https://arrow-kt.io/learn/quickstart/#additional-setup-for-plug-ins and added the following to my
build.gradle.kts
(the version is
1.2.0
and provided through version catalog):
Copy code
plugins {
    kotlin("jvm") version "1.9.21"
    id("com.google.devtools.ksp") version "1.8.21-1.0.11"
}

dependencies {
    implementation(libs.arrow.optics)
    implementation(libs.arrow.optics.ksp.plugin)
}
I then created some data classes annotated with `@optics`:
Copy code
@optics data class InsurancePolicy(val policyNumber: String, val insurant: Insurant, val vehicle: Vehicle) {companion object}
@optics data class Insurant(val firstName: String, val lastName: String, val address: Address) {companion object}
@optics data class Vehicle(val make: String, val model: String, val horsePower: Int) {companion object}
@optics data class Address(val street: String, val streetNumber: String, val zip: String, val city: String) {companion object}
but none of the companion object's properties seem to be generated (e.g.
InsurandPolicy.insurant
is not found)
g
If you are using gradle, make sure KSPDebug task is built. (Double check task name, I'm not sure)
d
I was missing the following line from the build output:
Copy code
ksp-1.8.21-1.0.11 is too old for kotlin-1.9.21. Please upgrade ksp or downgrade kotlin-gradle-plugin to 1.8.21.
but even after upgrading to
Copy code
id("com.google.devtools.ksp") version "1.9.21-1.0.16"
no code seems to be generated
d'oh! Just noticed my error:
Copy code
implementation(libs.arrow.optics.ksp.plugin)
should be
Copy code
ksp(libs.arrow.optics.ksp.plugin)
after fixing this and upgrading the plugin it now works
g
Okayy nice 👍