Skip to content

Ambiguous JPMS module reference in maven projects #2901

Open
@fzhinkin

Description

@fzhinkin

In maven projects, published "umbrella" artifacts (like "kotlinx-serialization-json") works as a gateway to corresponding -jvm artifacts. The former do not have a JPMS module bundled inside, so the module name is inferred from the artifact name. As a result, there are two artifacts providing the same module:

  • kotlinx-serialization-json provides kotlinx.serialization.json as it was inferred from the module name.
  • kotlinx-serialization-json-jvm provides kotlinx.serialization.json, well, because it actually provides it.

To Reproduce

Here's a reproducer: https://github.com/fzhinkin/kotlinx-serialization-jpms-conflict

$ mvm compile
...
[WARNING] /Users/filipp.zhinkin/.m2/repository/org/jetbrains/kotlinx/kotlinx-serialization-json-jvm/1.8.0/kotlinx-serialization-json-jvm-1.8.0.jar: (-1, -1) The root is ignored because a module with the same name 'kotlinx.serialization.json' has been found earlier on the module path at: /Users/filipp.zhinkin/.m2/repository/org/jetbrains/kotlinx/kotlinx-serialization-json/1.8.0/kotlinx-serialization-json-1.8.0.jar
[ERROR] /Users/filipp.zhinkin/Development/kotlinx-serialization-jmps-conflict/src/main/kotlin/Dummy.kt: (4, 30) Unresolved reference 'json'.
[ERROR] /Users/filipp.zhinkin/Development/kotlinx-serialization-jmps-conflict/src/main/kotlin/Dummy.kt: (10, 33) Unresolved reference 'Json'.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE

Expected behavior

"Umbrella" artifacts like kotlinx-serialization-core or kotlinx-serialization-json should provide some JPMS modules that won't clash with modules provided by actual ***-jvm artifacts.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions