chiroptical
12/20/2022, 2:37 PMchiroptical
12/20/2022, 2:38 PMsimon.vergauwen
12/20/2022, 2:39 PMchiroptical
12/20/2022, 2:40 PMproject(":test-processor")
to a scaffolded multiplatform project via IntelliJ.simon.vergauwen
12/20/2022, 2:41 PMproject(":test-processor")
needs to be replaced by the arrow-optics-ksp
dependencychiroptical
12/20/2022, 2:41 PMsimon.vergauwen
12/20/2022, 2:42 PMadd("kspCommonMainMetadata", "io.arrow-kt:arrow-optics-ksp-plugin:$arrowVersion")
chiroptical
12/20/2022, 2:43 PMkspJvm
. I think I get it. Will try during my lunch. Thanks Simon!chiroptical
12/20/2022, 4:20 PMProject with path 'io.arrow-kt:arrow-optics-ksp-plugin:1.1.3' could not be found in root project
I think I put the core/optics depends in commonMain
, i.e.
val arrowVersion = "1.1.3"
kotlin {
...
sourceSets {
val commonMain by getting {
dependencies {
implementation("io.arrow-kt:arrow-core:$arrowVersion")
implementation("io.arrow-kt:arrow-optics:$arrowVersion")
}
}
...
}
Then at the bottom in
dependencies {
add("kspCommonMainMetadata", project("io.arrow-kt:arrow-optics-ksp-plugin:$arrowVersion"))
}
chiroptical
12/20/2022, 4:26 PMchiroptical
12/20/2022, 10:43 PMproject("io.arrow...")
🤦chiroptical
12/20/2022, 11:10 PMcommonMain
code...simon.vergauwen
12/21/2022, 7:32 AMkspCommonMainMetadata
was for, but I've not used KSP in KMP.chiroptical
12/21/2022, 1:58 PMCould not determine the dependencies of task ':jsTestPackageJson'.
> Could not resolve all dependencies for configuration ':jsTestNpm'.
> Could not resolve io.arrow-kt:arrow-core:1.1.2.
Required by:
project :
> No matching variant of io.arrow-kt:arrow-core:1.1.2 was found. The consumer was configured to find a usage of 'kotlin-runtime' of a library, preferably optimized for non-jvm, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'js', attribute 'org.jetbrains.kotlin.js.compiler' with value 'legacy' but:
- Variant 'iosArm32ApiElements-published' capability io.arrow-kt:arrow-core:1.1.2 declares a library:
- Incompatible because this component declares a usage of 'kotlin-api' of a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native' and the consumer needed a usage of 'kotlin-runtime' of a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'js'
- Other compatible attributes:
- Doesn't say anything about its target Java environment (preferred optimized for non-jvm)
- Doesn't say anything about org.jetbrains.kotlin.js.compiler (required 'legacy')
This is where I am now. Is there a better place to ask for help here?simon.vergauwen
12/21/2022, 1:58 PMLEGACY
target only IR
.chiroptical
12/21/2022, 2:00 PMchiroptical
12/21/2022, 2:03 PMgenerated
directory now and can use optics in commonMain, but KSP throws an NPE. I probably have to configure the directories or something next.chiroptical
12/21/2022, 2:03 PMsimon.vergauwen
12/21/2022, 2:06 PMjs(IR) {
browser()
nodejs()
}
We should probably update https://github.com/arrow-kt/Arrow-MPP-Template/blob/main/build.gradle.kts to include Optics & KSP 🤔chiroptical
12/21/2022, 2:08 PMjs(IR) {
binaries.executable()
browser()
}
With nodejs()
, I get
Could not create task ':jvmProcessResources'.
> Task with name 'jsBrowserDistribution' not found in root project
chiroptical
12/21/2022, 2:09 PMsimon.vergauwen
12/21/2022, 2:09 PMsimon.vergauwen
12/21/2022, 2:09 PMjs(IR) {
is the important bitchiroptical
12/21/2022, 2:09 PMsimon.vergauwen
12/21/2022, 2:10 PM1.1.4-rc2
?chiroptical
12/21/2022, 2:11 PMchiroptical
12/21/2022, 2:12 PMsimon.vergauwen
12/21/2022, 2:12 PMsimon.vergauwen
12/21/2022, 2:12 PMchiroptical
12/21/2022, 2:13 PMsimon.vergauwen
12/21/2022, 2:13 PMchiroptical
12/21/2022, 2:13 PMchiroptical
12/21/2022, 2:14 PMchiroptical
12/21/2022, 5:35 PMsimon.vergauwen
12/21/2022, 6:15 PMchiroptical
12/21/2022, 6:25 PMchiroptical
12/21/2022, 10:41 PMsourceSets {
val commonMain by getting {
dependencies {
kotlin.srcDir(makeKspDir("commonMain"))
implementation("io.arrow-kt:arrow-core:$arrowVersion")
implementation("io.arrow-kt:arrow-optics:$arrowVersion")
}
}
}
where
fun makeKspDir(name: String) = file("build/generated/ksp/metadata/$name/kotlin")
It seems like it should be possible to do this for every target (terminology?) but hard to find a solution via google.chiroptical
12/21/2022, 10:42 PMchiroptical
12/21/2022, 10:48 PMchiroptical
12/21/2022, 10:57 PMjvmMain
, a file UseHello.kt
,
package app.shoebill.application
import Hello
import value
val x = Hello(0)
val y = Hello.value.modify(x) { it + 1 }
chiroptical
12/21/2022, 10:57 PMimport value
is pretty weird right? Is there no way to have packages in commonMain
?simon.vergauwen
12/22/2022, 7:42 AMTheYes, that is possible. Are they not respected?is pretty weird right? Is there no way to have packages inimport value
?commonMain
simon.vergauwen
12/22/2022, 7:42 AMQuestion, do you have a more elegant approach to setting the source directories for common optics?You can probably loop over the
kotlin.sourceSets
and set them that way in Gradle.chiroptical
12/22/2022, 12:58 PMchiroptical
12/22/2022, 2:26 PM.gradle
and things are working again. I feel like everything is just a bit more fragile with multiplatform at the moment.chiroptical
12/22/2022, 2:27 PM