kotlinx-datetime icon indicating copy to clipboard operation
kotlinx-datetime copied to clipboard

Add dependency on JVM version of the library to the POM file

Open ileasile opened this issue 4 years ago • 4 comments

We in Kotlin Jupyter kernel use Maven resolver for libraries resolution. Maven POM for kotlinx.datetime lacks any information of kotlinx-datetime-jvm dependency: https://repo1.maven.org/maven2/org/jetbrains/kotlinx/kotlinx-datetime/0.3.1/kotlinx-datetime-0.3.1.pom. So, when we import library like this:

@file:DependsOn("org.jetbrains.kotlinx:kotlinx-datetime:0.3.1")

we end up with an almost empty JAR without .class files, it only contains metadata files.

This fixes the issue:

@file:DependsOn("org.jetbrains.kotlinx:kotlinx-datetime-jvm:0.3.1")

The problem will be solved if the runtime dependency on kotlinx-datetime-jvm will be added to the POM file. I think, similar problem arises in Maven projects as well.

ileasile avatar Dec 17 '21 15:12 ileasile

In Maven JVM projects you should depend explicitly on kotlinx-datetime-jvm variant, like you do with any other Kotlin/MPP library.

I don't know the details behind @file:DependsOn dependency resolution mechanism, but probably it could be taught to support Gradle metadata in some limited form to resolve the correct dependency variant.

ilya-g avatar Dec 23 '21 00:12 ilya-g

In the pom file for the coroutines library, we do have a dependency on kotlinx-datetime-jvm: https://github.com/Kotlin/kotlinx.coroutines/blob/7a87eabcbd8a34d61490eb3e41033b24a5320918/gradle/publish-mpp-root-module-in-platform.gradle; https://github.com/Kotlin/kotlinx.coroutines/blob/7a87eabcbd8a34d61490eb3e41033b24a5320918/gradle/publish.gradle#L68-L69 We could add this to kotlinx-datetime as well.

dkhalanskyjb avatar Dec 01 '23 14:12 dkhalanskyjb

It turns out there's some problem with the way we do it in coroutines: https://github.com/Kotlin/kotlinx.coroutines/issues/3842. We'll need to look into it before we decide whether the datetime library should do the same.

dkhalanskyjb avatar Apr 12 '24 08:04 dkhalanskyjb

Seems like the main artifact should be the JVM jar with the Gradle module metadata. Then the common artifact is a separate artifact ID, like how the stdlib works.

JakeWharton avatar Apr 12 '24 12:04 JakeWharton