gnodet commented on PR #12745:
URL: https://github.com/apache/maven/pull/12745#issuecomment-6754324885

   _Claude Code on behalf of Guillaume Nodet_
   
   > means api=compile, implementation=runtime for consumer but compile for 
producer?
   
   Close but not quite. `implementation` is compile+runtime for the 
**producer** (the declaring module uses it normally), but for **consumers**:
   - **compile classpath**: NOT visible (non-transitive at compile time)
   - **runtime classpath**: visible (transitive at runtime)
   
   This is modeled at the resolver level, not just as a consumer POM mapping. 
The resolver natively excludes transitive `implementation` deps from compile 
resolution scopes while keeping them in runtime resolution scopes. The consumer 
POM mapping (`implementation` → `runtime`) is only for backward compatibility 
with Maven 3 consumers.
   
   > The common (and good) practice is to have an API module and an 
implementation module
   
   That's the right pattern when you have a clean API/impl split, but it forces 
a multi-module structure even when the "implementation" is just an internal 
dependency. If library A uses Guava internally, today you'd need to split A 
into `A-api` and `A-impl` just to hide Guava from consumers. With 
`implementation` scope, you keep A as a single module and declare Guava as 
`implementation` — same result, no structural overhead.
   
   > Technically I think there is no point having api scope
   
   The value of `api` is giving a coherent vocabulary. If only `implementation` 
existed, you'd write `<scope>compile</scope>` for public deps and 
`<scope>implementation</scope>` for internal ones. `compile` describes *when*, 
`implementation` describes *visibility* — they're not on the same axis. 
`api`/`implementation` gives a consistent pair: what's part of your contract 
vs. what's internal. It's the same reason Gradle deprecated `compile` in favor 
of `api`.
   
   > A better solution sounds like enabling to explicit the consumer pom scope 
in a new tag
   
   That approach would only work through the consumer POM (published 
artifacts). It wouldn't work in reactor builds where modules resolve against 
each other directly — the consumer POM isn't involved. Our approach models 
transitivity at the resolver level, so it works identically in reactor builds 
and published artifact resolution. No special POM syntax needed.
   
   > another ambiguity is the scope: the module, the full project, every 
subreactors?
   
   Per-module, like all dependency declarations. Each module declares its own 
dependencies as `api` or `implementation`. In a multi-module project, module B 
depending on module A sees A's `api` deps transitively at compile time, but not 
A's `implementation` deps. Module A's `implementation` deps are A's private 
concern — which is exactly the point.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to