Arjan van Wieringen
05/26/2023, 9:54 AMArjan van Wieringen
05/26/2023, 9:54 AMplugins {
kotlin("multiplatform")
id("com.google.devtools.ksp")
}
kotlin {
js(IR) {
browser()
}
jvm()
sourceSets["commonMain"].dependencies {
implementation(libs.uuid)
implementation(libs.arrow.core)
implementation(libs.arrow.optics)
}
}
dependencies {
add("kspCommonMainMetadata", "io.arrow-kt:arrow-optics-ksp-plugin:1.2.0-RC")
add("kspJvm", "io.arrow-kt:arrow-optics-ksp-plugin:1.2.0-RC")
add("kspJs", "io.arrow-kt:arrow-optics-ksp-plugin:1.2.0-RC")
}
Arjan van Wieringen
05/26/2023, 9:55 AMpackage nl.avwie.flow.model
import arrow.optics.optics
@optics
data class Person(val name: String, val age: Int, val address: Address) {
companion object
}
@optics
data class Address(val street: Street, val city: City) {
companion object
}
@optics
data class Street(val name: String, val number: Int?) {
companion object
}
@optics
data class City(val name: String, val country: String) {
companion object
}
Arjan van Wieringen
05/26/2023, 9:56 AMpublic inline val nl.avwie.flow.model.Address.Companion.iso: arrow.optics.Iso<nl.avwie.flow.model.Address, kotlin.Pair<nl.avwie.flow.model.Street, nl.avwie.flow.model.City>> inline get() = arrow.optics.Iso(
get = { address: nl.avwie.flow.model.Address -> kotlin.Pair(address.`street`, address.`city`) },
reverseGet = { pair: kotlin.Pair<nl.avwie.flow.model.Street, nl.avwie.flow.model.City> -> nl.avwie.flow.model.Address(pair.first, pair.second) }
)
But I can't use them anywhere. It can not resolve this code anywhere.Arjan van Wieringen
05/26/2023, 10:03 AMtasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinCompile<*>>().all {
if (name != "kspCommonMainKotlinMetadata") {
dependsOn("kspCommonMainKotlinMetadata")
}
}
kotlin.sourceSets.commonMain {
kotlin.srcDir("build/generated/ksp/metadata/commonMain/kotlin")
}
simon.vergauwen
05/26/2023, 10:39 AMsimon.vergauwen
05/26/2023, 10:39 AMArjan van Wieringen
05/26/2023, 12:20 PMArjan van Wieringen
05/26/2023, 12:31 PMtasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinCompile<*>>().all {
if (name != "kspCommonMainKotlinMetadata") {
dependsOn("kspCommonMainKotlinMetadata")
}
}
Causes the build
to fail with:
A problem was found with the configuration of task ':features:model:features-model-domain:compileKotlinJs' (type 'Kotlin2JsCompile').
- Gradle detected a problem with the following location: '/Users/avanwieringen/Development/private/kotlin/flow/features/model/domain/build/generated/ksp/metadata/commonMain/kotlin'.
* Try:
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
* Exception is:
org.gradle.internal.execution.WorkValidationException: A problem was found with the configuration of task ':features:model:features-model-domain:compileKotlinJs' (type 'Kotlin2JsCompile').
- Gradle detected a problem with the following location: '/Users/avanwieringen/Development/private/kotlin/flow/features/model/domain/build/generated/ksp/metadata/commonMain/kotlin'.
Reason: Task ':features:model:features-model-domain:compileKotlinJs' uses this output of task ':features:model:features-model-domain:kspCommonMainKotlinMetadata' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed.
Possible solutions:
1. Declare task ':features:model:features-model-domain:kspCommonMainKotlinMetadata' as an input of ':features:model:features-model-domain:compileKotlinJs'.
2. Declare an explicit dependency on ':features:model:features-model-domain:kspCommonMainKotlinMetadata' from ':features:model:features-model-domain:compileKotlinJs' using Task#dependsOn.
3. Declare an explicit dependency on ':features:model:features-model-domain:kspCommonMainKotlinMetadata' from ':features:model:features-model-domain:compileKotlinJs' using Task#mustRunAfter.
Please refer to <https://docs.gradle.org/8.0/userguide/validation_problems.html#implicit_dependency> for more details about this problem.
at org.gradle.internal.execution.WorkValidationException$BuilderWithSummary.build(WorkValidationException.java:133)