https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
a

andylamax

06/04/2021, 12:28 AM
Hello, forgive me if this is the wrong channel, but. I would love to know how the kotlin libraries (i.e. kotlinx-serialization, kotlin-stdlib-jdk8) are compiled and they support all the versions of java. Starting from jdk8 to jdk15?
When I add a maven dependency (in a project targeting java 15) that was built by kotlin 1.5.0 targeting java 8, I get
Copy code
> The consumer was configured to find an API of a library compatible with Java 15, preferably in the form of class files, and its dependencies declared externally. However we cannot choose between the following variants of tz.co.asoft:test-core:1.1.30:
          - debugApiElements-published
          - debugRuntimeElements-published
          - jvmApiElements-published
          - jvmRuntimeElements-published
          - releaseApiElements-published
          - releaseRuntimeElements-published
r

rnett

06/04/2021, 12:37 AM
I've seen similar due to https://youtrack.jetbrains.com/issue/KT-35003, you can add
attributes { attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 8) }
to the Kotlin target manually. The error usually says something about that though, so I'm not sure if that's your issue. And I've only seen it when building the dependency on a JDK > than the one I'm using.
You can run
outgoingVariants
on your dependency project vs on a cloned Kotlinx.serialization or w/e and compare, worst case scenario. My other guess is that
debug
and
release
artifacts aren't supposed to be published, or you have some other issue with your publishing. For reference,
outgoingVariants
on one of my multiplatform projects looks like https://gist.github.com/rnett/5f1acba4c1d6c0482e17c126a318dae9
a

andylamax

06/04/2021, 12:48 AM
So, I tried adding the attributes, but still getting a problem
This is a portion of what is being printed on the console
Copy code
The consumer was configured to find an API of a library compatible with Java 15, preferably in the form of class files, and its dependencies declared externally. However we cannot choose between the following variants of tz.co.asoft:test-core:1.1.30:
          - debugApiElements-published
          - debugRuntimeElements-published
          - jvmApiElements-published
          - jvmRuntimeElements-published
          - releaseApiElements-published
          - releaseRuntimeElements-published
        All of them match the consumer attributes:
r

rnett

06/04/2021, 12:52 AM
Almost definitely going to be a publishing problem, then. I'd look at
outgoingVariants
in the dependency
a

andylamax

06/04/2021, 12:57 AM
Funny thing is, I bring down the targetCompatibility to 1.8, everything is resolved. So, If its a publishing thing, then it is a gradle metadata issue
r

rnett

06/04/2021, 1:00 AM
That's odd, you should be definitely able to depend on something targeting an earlier JDK. Probably worth a youtrack issue