Lukasz Kalnik
07/08/2022, 2:20 PMplugins {
id("com.google.devtools.ksp")
}
dependencies {
implementation("io.arrow-kt:arrow-optics:$arrowVersion")
ksp("io.arrow-kt:arrow-optics-ksp-plugin:$arrowVersion")
}
I have also annotated my data classes:
@optics
data class ConnectorWithSensors(
val connector: Connector,
val sensors: List<ItemSelection>,
) {
companion object
}
@optics
data class ItemSelection(
val id: String,
val selected: Boolean,
) : {
companion object
}
However I cannot access the extensions generated on companion object like ConnectorWithSensors.sensors
.Alejandro Serrano Mena
07/08/2022, 3:04 PM./gradlew build
work? if so, the KSP plugin is working
2. if the problem is only in the IDE, this means you need to add the generated sources as explained here. My suggestion is to add the following then to your gradle file
plugins {
// ...
idea
}
idea {
module {
// Not using += due to <https://github.com/gradle/gradle/issues/8749>
sourceDirs = sourceDirs + file("build/generated/ksp/main/kotlin") // or tasks["kspKotlin"].destination
testSourceDirs = testSourceDirs + file("build/generated/ksp/test/kotlin")
generatedSourceDirs = generatedSourceDirs + file("build/generated/ksp/main/kotlin") + file("build/generated/ksp/test/kotlin")
}
}
Lukasz Kalnik
07/08/2022, 3:18 PMinternal
.
So ksp complained that "public member exposes internal type" in the generated code.
After making the data classes public the project builds, however the extension property ConnectorWithSensors.sensors
is still red. I will try to import the generated sources as you suggested.