A lot of Java projects shade their dependencies. I believe the main reason is illustrated by the answer on this SO question (What is the maven-shade-plugin used for, and why would you want to relocate Java packages?). To summarize:
- Library Foo has dependency Bar:1.0 and can't upgrade to Bar:2.0
- Qux depends on library Foo but also depends on Bar:2.0
- Without shading, Bar:1.0 and Bar:2.0 would conflict, so library Foo uses a shaded version of Bar and depends on this shaded version to not negatively impact downstream projects that wish to use a different version of Bar.
My question is does Java Modules (JPMS/Jigsaw) also solve this problem without the need for shading? I understand that today, most Java projects aren't using JPMS, but in the scenario that Qux/Foo/Bar were all fully using JPMS modules, could they avoid conflicts without Foo needing to use a shaded version of Bar?