Details
-
Improvement
-
Status: Open
-
Major
-
Resolution: Unresolved
-
4.0.0
-
None
-
None
Description
(This is the suggestion that melix made at the end of khmarbaise's recent IDEA Conf talk on Maven 4. I couldn't find an existing issue for it, so I made this one – please link it if I missed a previously existing one.)
In Maven, compile scope dependencies by default are exported as transitive dependencies. This leads to developers relying on transitive dependencies in their code (often accidentally), then breakage when some depencies change, and overuse of <exclusions> trying to fix it.
Maven 4 with its new modelVersion gives us the chance for a better solution:
- The compile scope should be changed to not transitively export dependencies.
- A new scope named api should be added, signalling that dependencies with this scope become part of the modules API (and therefore become transitive dependencies for users of this module). This one essentially behaves like the compile scope before.
I believe that this will lead to smaller compile classpaths (faster and better code completion in IDEs, faster compilation), less fragile builds (less accidental reliance on transitive dependencies) and less dependency issues for developers overall. It also aligns nicely with how the Gradle Java plugin does it (api/implementation).
It will however break some builds which are relying on implicit transitive dependencies – and while that's kind of the point, it should only be done with the new modelVersion to opt into.