Internal Maven dependencies

Viewed 60

Is there a way in Maven for a library module A to specify a internal dependency on a module B, but without this fact being visible to clients of A?

That is, if C declares dependency on A, C can not use any code from B without declaring it's own dependency on B.

Motivation

The reason for why I want this is that I want to be able to remove the dependency on B whenever I like, without clients being affected.

Difference from provided and optional

This is different from provided and optional dependencies. An internal dependency would have nothing to do with whether it is provided by a app container, or if it is a dependency that is only available sometimes.

This question is about a kind of dependency that is always distributed together with the module A, but that is not visible to clients.

Similar thing in Gradle

This is the same as the distinction between implementation and api dependencies in Gradle.

Related question

This seem to ask about the same thing. But the poster accepted optional dependencies as a solution. So in practice this question is about something different:

Maven private dependencies

1 Answers

AFAIK, there is no solution for this on the level of A.

It would be be possible to use dependency:analyze or dependency:analyze-only in C to determine whether a transitive dependency was used without declaring it.

Related