'Maven with-dependencies artifact to not pass dependencies forward

ProjectA needs to package ProjectB inside in an assembly. So ProjectA declares ProjectB as a dependency. ProjectB (type pom) produces a zip artifact, containing all needed dependencies inside. My issue is that, when declaring ProjectB as dependency of ProjectA, ProjectA receives all transitive dependencies of ProjectB. Is there a way to have ProjectB publish its zip artifact with a pom which has no dependencies?

I'm not after quick fixes (optional, exclude, provided, etc. they are not meant for this use case). I want to learn the proper way maven was intended to be used. One project has dependencies (for compilation, for packaging), but the artifact it produces should not declare dependencies for being used by another project, because it has all it needs.

When a plugin attaches an artifact, it is attached to the same pom of the project producing it. What's the proper way to produce a "with dependencies" artifact which would not declare dependencies in the pom it installs in the maven repo, but has the dependencies in the pom which with it is built?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source