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

Projects not modular, duplicate packages across JARs #3204

Open
credmond opened this issue Dec 7, 2024 · 3 comments
Open

Projects not modular, duplicate packages across JARs #3204

credmond opened this issue Dec 7, 2024 · 3 comments

Comments

@credmond
Copy link

credmond commented Dec 7, 2024

There are projects that "export" the same packages (com.squareup.wire).

E.g.: wire.runtime.jvm and wire.schema.jvm

...which leads to errors like this, when building modular projects.

Error occurred during initialization of boot layer
java.lang.module.ResolutionException: Modules wire.runtime.jvm and wire.schema.jvm export package com.squareup.wire to module <something>

I don't know about the KT world, but this in a breach of JPMS guidelines.

Why can't we have modules-info.java or at least why do you have different JARs with the same packages?

Or am I missing something altogether in how to use these libs...

@oldergod
Copy link
Member

Assuming that JPMS is for Java Platform Module System, I fail to see what exporting means here.
Different modules can't have classes defined in the same package? If modules-info.java can fix it, that'd be great if you could push a PR.

@JakeWharton
Copy link
Collaborator

Why can't we have modules-info.java

We can, but it involves doing separate compilation and creating a MR jar because our minimum is below 9.

why do you have different JARs with the same packages?

Because effectively no one uses modules, this project predates modules existing, and no one has complained.

We can probably just move the schema type that offends. Binary compatibility of that module has been broken many times without a major version bump before.

If we do this, is the automatic module name still enough, or is there an actual reason to do module definitions?

@credmond
Copy link
Author

Assuming that JPMS is for Java Platform Module System, I fail to see what exporting means here. Different modules can't have classes defined in the same package? If modules-info.java can fix it, that'd be great if you could push a PR.

Yes, you cannot have two modules (i.e., JARs) with the same packages containing classes intended for external use, i.e., where the same package gets "exported" twice.

modules-info.java cannot fix it alone, the classes would need to be moved in one of the two conflicting projects, assuming they're classes that you need exposed. I've noticed this sort of thing in quite a few square modules, in the past.

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

No branches or pull requests

3 participants