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

   _Claude Code on behalf of Guillaume Nodet_
   
   > means api=compile, implementation=runtime for consumer but compile for 
producer?
   
   Yes, exactly.
   
   The main driver for this feature is enforcing proper dependency 
declarations. Today, `dependency:analyze` warns about "used but undeclared" 
transitive deps — but it's a post-hoc warning that developers may ignore. With 
`implementation`, the compiler enforces it: if library A declares Guava as 
`implementation`, consumers cannot accidentally compile against A's transitive 
Guava. If they need Guava, they must declare it themselves. This is something 
people should be able to do without having to think about it.
   
   > The common (and good) practice is to have an API module and an 
implementation module so downstream consumers can have the api in scope provided
   
   `provided` is fundamentally a deployment-time concept ("something else will 
supply this at runtime"), not a build-time visibility concept. Using it to 
control API visibility is a misuse — it makes the API non-transitive, forcing 
every consumer to redeclare it explicitly, which is the opposite of what an API 
dependency should be. It also breaks when the deployment context changes: the 
`maven-plugin-plugin` forces Maven jars to `provided` because you deploy inside 
Maven, but if Maven changes which jars it exposes, you have to adjust your 
scopes even though your library hasn't changed. `api`/`implementation` 
addresses build-time visibility directly, without conflating it with deployment 
concerns.
   
   > Technically I think there is no point having api scope
   
   `compile`/`implementation` as a pair is semantically incoherent — `compile` 
describes *when*, `implementation` describes *visibility*. 
`api`/`implementation` gives a consistent pair on the same axis.
   
   > A better solution sounds like enabling to explicit the consumer pom scope 
in a new tag
   
   That would only work through the consumer POM, not in reactor builds where 
modules resolve against each other directly. Our approach models transitivity 
at the resolver level, so it works identically in both cases.
   
   > another ambiguity is the scope: the module, the full project, every 
subreactors?
   
   Per-module, like all dependency declarations.


-- 
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