I'd like to integrate arrow-optics in a multiplatf...
# arrow
n
I'd like to integrate arrow-optics in a multiplatform project (and this is my first try to use the arrow-optics code generator). The files I modified: build.gradle.kts
Copy code
plugins {
    ...
    id("com.google.devtools.ksp") version "1.6.10-1.0.2"
}

kotlin {
    sourceSets {
        val commonMain by getting {
            dependencies {
                ...
                api("io.arrow-kt:arrow-optics:1.0.1")
            }
        ...
    }
}

dependencies {
    ksp("io.arrow-kt:arrow-optics-ksp-plugin:1.0.2-alpha.28")
}
Example.kt
Copy code
...
@optics
data class Example(val p: String) {
    companion object
}
But no files are generated, the
build\generated\xxxMain
folders are created but remain empty. During the build process the corresponding tasks are executed (and I see a warning):
Copy code
...
The 'ksp' configuration is deprecated in Kotlin Multiplatform projects. Please use target-specific configurations like 'kspJvm' instead.
...
Task ... kspKotlinJs UP-TO-DATE
...
Task ... kspKotlinMetadata UP-TO-DATE
...
Task ... kspKotlinJvm UP-TO-DATE
...
Do you have any idea what piece is missing? Thanks.
s
Hey @Norbi,
ksp
doesn’t work for Kotlin MPP afaik. You need to use a special configuration for MPP KSP. https://github.com/google/ksp/blob/main/examples/multiplatform/workload/build.gradle.kts
🙏 1
n
Thanks. I tried this modification but still no files are generated :(
Copy code
dependencies {
    val arrowPluginLib = "io.arrow-kt:arrow-optics-ksp-plugin:1.0.2-alpha.28"
    add("kspMetadata", arrowPluginLib)
    add("kspJvm", arrowPluginLib)
    add("kspJvmTest", arrowPluginLib)
    add("kspJs", arrowPluginLib)
    add("kspJsTest", arrowPluginLib)
}
Hmmm, I've just converted the project to a simple Kotlin/JVM project and still no luck with ksp code generation. So probably I miss something fundamental... Does the Java version matter? I use Java 17. (EDIT: I tried with Java 11, still no luck.) Maybe the arrow-optics plugin interferes with the compose compiler plugin? Do you have experience with these? Thanks.
I've uploaded a simple sample project, could you please take a look at it? Maybe you spot some problem... Thanks. https://github.com/NorbertSandor/compose-desktop-jvm-sample-app
s
Hey @Norbi, I was out in the afternoon. I will look into it tomorrow. Thanks for uploading a reproducible example!
🙏 1
🙏🏻 1
n
@simon.vergauwen, did you have time to take a look at it? Thanks.
s
Hey @Norbi. I did, but I can not get any code to generate either 😞 Looking into what broke with @Alejandro Serrano Mena & @Imran/Malic. I cannot see the KSP library in the “external libraries” in IDEA window either 🤔
🙏 1
a
I’m going to have a look at it, and hopefully report back soon
🙏 1
🙏 1
I’m happy to report that I think I’ve found the solution https://github.com/arrow-kt/arrow/pull/2649, unfortunately it seems that the solution collides with the way we do publication 😞
😞 1
🙌🏻 1
🙏 1
n
"the solution collides with the way we do publication" - @Alejandro Serrano Mena, do you have a rough guess when can we expect a release with this issue fixed? Thanks.
s
We’re working on publications for quite some time. We think we got it properly set up now 🤞 Could you try
1.0.2-alpha.43
@Norbi?
👍🏻 1
I haven’t had a chance myself to test, if I do I’ll report status back here
n
@simon.vergauwen, it works in my JVM-only Compose/Desktop + Arrow sample project 🙌🏻: https://github.com/NorbertSandor/compose-desktop-jvm-sample-app (I've committed the necessary changes.) But I couldn't make it to work in my multiplatform project, so I will create a sample project for multiplatform as well.
🙌 1
a
I was coming here to report back, but it seems that @simon.vergauwen has already done it 🙂
🙏 1
🙌 1
n
@Alejandro Serrano Mena, @simon.vergauwen, I've run into a strange problem: the generated code references properties
a
,
b
,
c
,
d
of type
arrow.core.Tuple4
but the actual names of the corresponding properties are
first
,
second
,
third
,
fourth
. Could this be a problem of my project configuration? (As I see every Arrow dependency is of version 1.0.2-alpha.43 .)
i
Nop Arrow changed to
first
,
second
third
prior to 1.0.0 release. So it’s agnostic to the kotlin stdlib
s
This means the generator in Optics KSP is oudated.
👍🏾 1
n
"it’s agnostic to the kotlin stdlib" - In my single-module sample project it works as expected, but in my multi-module project it fails because of the
a
vs
first
problem. Both projects are based on Kotlin 1.6.10, so I don't get how the Kotlin stdlib affects this...
s
we renamed
a
to
first
to be more in line with Kotlin Std naming, that was a change prior to 1.x.x though.
👍🏻 1
This has been fixed before, but it was fixed in Arrow while this was already living in Arrow Meta.. and now moved back… So fix wasn’t applied 😕 it’s an easy fix, and we caught it before actual release so thank you a lot for the testing and reporting @Norbi! I can fix it later today, and send another
alpha
your way tomorrow to try if it is fixed.
🙏 1
i
the previous PR from @simon.vergauwen has been merged, and I pushed a release for
<https://github.com/arrow-kt/arrow/tree/1.0.3-alpha.1|1.0.3-alpha.1>
, in a few hours it should be ready for testing it out @Norbi 😄
🙌🏻 1
n
@Imran/Malic, @simon.vergauwen, @Alejandro Serrano Mena, now it works, thanks for the effort and the quick fix 🙌🏻
🙌🏾 1
🙌 1
201 Views