Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ambiguous module reference: kotlinx.coroutines.core #3842

Open
oryan-block opened this issue Aug 9, 2023 · 9 comments
Open

Ambiguous module reference: kotlinx.coroutines.core #3842

oryan-block opened this issue Aug 9, 2023 · 9 comments
Labels

Comments

@oryan-block
Copy link

Describe the bug

I'm trying to upgrade to v1.7.3 and add the modules to a module-info file but it seems that kotlinx-coroutines-core and kotlinx-coroutines-core-jvm cause a problem because they have the same module name (I think)

image

My pom dependencies:

        <dependency>
            <groupId>org.jetbrains.kotlinx</groupId>
            <artifactId>kotlinx-coroutines-core</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jetbrains.kotlinx</groupId>
            <artifactId>kotlinx-coroutines-jdk9</artifactId>
        </dependency>

This seems to happen because kotlinx-coroutines-core-jvm is a dependency of kotlinx-coroutines-jdk9 and it's module name is kotlinx-coroutines-core. At the same time kotlinx-coroutines-core has an implied module name which is its package name.
Am I importing these dependencies wrong?

@oryan-block oryan-block added the bug label Aug 9, 2023
@qwwdfsad
Copy link
Collaborator

qwwdfsad commented Aug 9, 2023

Would it be okay for you to attach a reproducing project?

I'm trying to upgrade to v1.7.3

Could you please elaborate on what version you are upgrading from?

@oryan-block
Copy link
Author

@qwwdfsad try to checkout this branch: https://github.com/graphql-java-kickstart/graphql-java-tools/tree/upgrade-java-11

Upgrading from v1.6.4

@oryan-block
Copy link
Author

btw if I replace these deps with kotlinx-coroutines-core-jvm the warning is gone, but that doesn't seem to be the way to import the project according to the docs

@mjovanc
Copy link
Contributor

mjovanc commented Aug 29, 2023

@oryan-block Is this still an issue for you? The way I see it you should not add the extension -jvm, it should only be kotlinx-coroutines-core. The packages for the specific platform will be present and common ones.

I could not find the branch now to test.

@oryan-block
Copy link
Author

@mjovanc yes this is still a problem. This happens even if I only import kotlinx-coroutines-core
Please check this branch: https://github.com/graphql-java-kickstart/graphql-java-tools/tree/coroutinies-module-reference

@dkhalanskyjb
Copy link
Collaborator

In Maven projects, it's ok to depend on the -jvm variant of the Kotlin Multiplatform libraries. In fact, it's more straightforward: all kotlinx-coroutines-core should do in Maven is specify a dependency on kotlinx-coroutines-core-jvm for convenience. I'm not sure why also having kotlinx-coroutines-core in the dependencies causes a warning. Is it only in the IDE, or can you observe it when building the project?

@oryan-block
Copy link
Author

oryan-block commented Feb 9, 2024

@dkhalanskyjb it's not just the IDE, maven also fail to build because it can't see anything in the ambiguous module. Depending on -jvm fixes it. Should the readme be fixed?

I'm not sure why also having kotlinx-coroutines-core in the dependencies causes a warning

Not 100% sure but I do believe it's because both core and core-jvm end up with the same module name.

@fzhinkin
Copy link
Contributor

fzhinkin commented Jan 3, 2025

The issue arise because kotlinx-coroutines-core.jar does not contain a JPMS module, so the JPMS module name is derived from the jar file name (kotlinx.coroutines.core). And that module name conflicts with the actual kotlinx.coroutines.core module when the kotlinx-coroutines-core-jvm dependency is fetched.

As a workaround, we can set some automatic module name explicitly using the Automatic-Module-Name manifest header.
Something like Automatic-Module-Name: kotlinx.coroutines.core.trampoline :)

@oryan-block
Copy link
Author

@fzhinkin yep, just need to resolve that conflict.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants