[ 
https://issues.apache.org/jira/browse/MNG-8099?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Henning Hoefer updated MNG-8099:
--------------------------------
    Description: 
{color:silver}(This is the suggestion that [~melix] made at the end of 
[~khmarbaise]'s recent [IDEA Conf talk on Maven 
4|https://www.youtube.com/watch?v=tAGv4QH29QU]. I couldn't find an existing 
issue for it, so I made this one – please link it if I missed a previously 
existing one.){color}

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.

  was:
{color:silver}(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.){color}

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.


> Add explicit "api" scope for dependencies
> -----------------------------------------
>
>                 Key: MNG-8099
>                 URL: https://issues.apache.org/jira/browse/MNG-8099
>             Project: Maven
>          Issue Type: Improvement
>          Components: Dependencies, POM
>    Affects Versions: 4.0.0
>            Reporter: Henning Hoefer
>            Priority: Major
>
> {color:silver}(This is the suggestion that [~melix] made at the end of 
> [~khmarbaise]'s recent [IDEA Conf talk on Maven 
> 4|https://www.youtube.com/watch?v=tAGv4QH29QU]. I couldn't find an existing 
> issue for it, so I made this one – please link it if I missed a previously 
> existing one.){color}
> 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.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to