Closed jillesvangurp closed 2 years ago
api
would cause the dependency to become transitive again and I think the user of konform should be free to decide what version of Kotlin to use.
What is your build error looking like?
I don't think you can avoid dependencies on the standard library. CompileOnly causes issues with multi platform builds. It complains it can't find js and jvm variants.
> The consumer was configured to find a usage of 'kotlin-api' of a library, preferably optimized for non-jvm, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'common'. However we cannot choose between the following variants of io.konform:konform:0.4.0:
- jsIrApiElements-published
- jsLegacyApiElements-published
- jvmApiElements-published
- jvmRuntimeElements-published
All of them match the consumer attributes:
- Variant 'jsIrApiElements-published' capability io.konform:konform:0.4.0 declares a usage of 'kotlin-api' of a library, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'js':
- Unmatched attributes:
- Doesn't say anything about its target Java environment (preferred optimized for non-jvm)
- Provides release status but the consumer didn't ask for it
- Provides attribute 'org.jetbrains.kotlin.js.compiler' with value 'ir' but the consumer didn't ask for it
- Variant 'jsLegacyApiElements-published' capability io.konform:konform:0.4.0 declares a usage of 'kotlin-api' of a library, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'js':
- Unmatched attributes:
- Doesn't say anything about its target Java environment (preferred optimized for non-jvm)
- Provides release status but the consumer didn't ask for it
- Provides attribute 'org.jetbrains.kotlin.js.compiler' with value 'legacy' but the consumer didn't ask for it
- Variant 'jvmApiElements-published' capability io.konform:konform:0.4.0 declares an API of a library, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm':
- Unmatched attributes:
- Doesn't say anything about its target Java environment (preferred optimized for non-jvm)
- Provides its elements packaged as a jar but the consumer didn't ask for it
- Provides release status but the consumer didn't ask for it
- Variant 'jvmRuntimeElements-published' capability io.konform:konform:0.4.0 declares a runtime of a library, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm':
- Unmatched attributes:
- Doesn't say anything about its target Java environment (preferred optimized for non-jvm)
- Provides its elements packaged as a jar but the consumer didn't ask for it
- Provides release status but the consumer didn't ask for it
The following variants were also considered but didn't match the requested attributes:
- Variant 'jsIrRuntimeElements-published' capability io.konform:konform:0.4.0 declares a library, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'js':
- Incompatible because this component declares a usage of 'kotlin-runtime' of a component and the consumer needed a usage of 'kotlin-api' of a component
- Other compatible attribute:
- Doesn't say anything about its target Java environment (preferred optimized for non-jvm)
- Variant 'jsLegacyRuntimeElements-published' capability io.konform:konform:0.4.0 declares a library, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'js':
- Incompatible because this component declares a usage of 'kotlin-runtime' of a component and the consumer needed a usage of 'kotlin-api' of a component
- Other compatible attribute:
- Doesn't say anything about its target Java environment (preferred optimized for non-jvm)
- Variant 'metadataApiElements' capability io.konform:konform:0.4.0 declares a library, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'common':
- Incompatible because this component declares a usage of 'kotlin-metadata' of a component and the consumer needed a usage of 'kotlin-api' of a component
- Other compatible attribute:
- Doesn't say anything about its target Java environment (preferred optimized for non-jvm)
0.3.0 did not have that issue
you might try implementation
instead of api
I copied the konform src into our codebase for now but I'd be happy to test if you do another release.
Can you link the commit where this fails? Or maybe share the dependencies section of the gradle build file?
this is a private build of our project. The only difference is changing 0.3.0 to 0.4.0
Not sure what's going on here. Can you at least share:
kotlin
section for your Gradle buildI have created a bunch of projects (Multiplatform JVM/JS, JVM, Kotlin/JS) with Kotlin versions 1.5 and 1.6 and the only way I can get this to fail is when using Kotlin 1.5 and the IR backend (Edit: but with a very different error). This is not too worrisome though as the IR backend in Kotlin 1.5 was only beta anyways.
For example a project with this configuration works without issues:
plugins {
kotlin("multiplatform") version "1.6.21"
}
group = "io.konform.examples"
repositories {
mavenCentral()
}
kotlin {
js(BOTH) {
browser()
nodejs()
}
sourceSets {
val commonMain by getting {
dependencies {
implementation("io.konform:konform:0.4.0")
}
}
val commonTest by getting {
dependencies {
implementation(kotlin("test"))
}
}
val jsMain by getting
val jsTest by getting
}
}
I've tested using Gradle 7.3 and 7.4.
FYI with regard to
I think compileOnly is sort of deprecated in any case.
This is not the case. compile
has been deprecated in favour of api
and implementation
but compileOnly
is exactly for this use-case:
Sorry for being slow to respond. I tracked down the issue to our use of the legacy js compiler in the end. Sorry about wasting your time. And thank you for your support.
No worries. Thanks for coming back on this one.
causing issues with our build
use api instead. I think compileOnly is sort of deprecated in any case.