Let us say, ArtifactA depends on ArtifactB and ArtifactC also depends on ArtifactB
I understand that "mvn dependency plugin" can help list the dependencies of a project/artifact.
But how about the reverse? If I want to find the list of projects/artifacts which depend on a given artifact? From the above example, given ArtifactB, I would like to get ArtifactA and ArtifactC
How can I achieve this?
Maven can only operate on the current project, so it can only detect dependencies between from the current project (or sub-modules) to other projects (including sub-modules of the current project).
So what you can do is search for specific submodules depending on other submodules:
mycompany:parent
/ \
mycompany:child1 mycompany:child2
/ / \
mycompany:grandchild1 mycompany:grandchild2 mycompany:grandchild3
This is how you can find all subprojects that have dependencies to grandchild3:
mvn validate -pl child2/grandchild3 -amd
This will run the validate
phase on all projects within the current project that depend on grandchild3.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With