6

So, I'm trying to migrate a tool from Java 8 to Java 11.
I did the first step to make it work without modules and the code compiles successfully.

Now I'm trying to add the module-info.java, and I first faced issues because of the libraries used in my tool. Some are already compatible with Java 11 (e.g. Lombok) but some others are not, so I'm trying to import them using the requires and the artifactId name.
But I seem stuck because of my Maven model & Maven model builder dependency as I get the following error when building:

[ERROR] the unnamed module reads package org.apache.maven.model.merge from both maven.model.builder and maven.model
[ERROR] module maven.model.builder reads package org.apache.maven.model.merge from both maven.model.builder and maven.model
[ERROR] module maven.model reads package org.apache.maven.model.merge from both maven.model.builder and maven.model

What should I do for this kind of error? It seems I need both (build still fails if I comment one or the other). Does it mean I cannot add modules to my tool because of my dependencies?
N.B.: The libraries are set to their latest version (i.e. 3.6.3)

4
  • The module system does not allow split packages. Are there newer versions of your dependencies that may have fixed the problem? Commented Mar 29, 2020 at 14:52
  • I tried upgrading to the latest one (3.6.3) but the issue persists Commented Mar 29, 2020 at 15:16
  • I am also facing the same issue. I got compile by excluding like this following but it will cause run time issues, just wondering is there any other module to exclude? implementation ('org.apache.maven:maven-resolver-provider:3.6.3') { exclude group: 'org.apache.maven.model.merge' , module: 'maven-model-merge' } Commented Sep 29, 2020 at 6:10
  • Well, I didn't manage to solve this, so I abandoned the move to JPMS... What a shame Commented Sep 30, 2020 at 18:46

1 Answer 1

0

I "fixed" this using the maven-exec-plugin as described in the answer to this question.

Edit: When running the main class through the maven-exec-plugin, the compiler does (for some reason unknown to me) not complain anymore about the conflicts.

Sign up to request clarification or add additional context in comments.

3 Comments

I'm not sure I understand the link between the exec plugin and this split package issue
Well IntelliJ complained about some packages that where exported to the same module (just as you described in you question), and I could not seem to get it fixed. However, when I run the main class via the exec plugin, those conflicting exports are not there anymore, and you can then run your program via the plugin. It is a dirty "solution" but it "works"
Oh, this is surprising!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.