I have a multi-module project that has two modules A and B. Both have their own modules, here on refered as sub-modules.
I want to do some comparison between both types of modules. For example, I want to check that all sub-modules of A should have an associated sub-module in B. How can I do that?
I looked into maven-enforcer-plugin, but I only found examples of managing plugins and dependencies, not modules.
So far, I have been able to print out list of sub-modules of A using following command from this link:
mvn --also-make dependency:tree | grep maven-dependency-plugin | awk '{ print $(NF-1) }'
But when I try to output that to a file like this :
mvn dependency:list -DoutputFile="foo.txt"
I see that foo.txt
is created in each and every sub-module of A, rather than module A(the aggregator). I need one single file with the list of dependencies, from which I can filter out the modules using
grep maven-dependency-plugin | awk '{ print $(NF-1) }'
So I need two things:
1. output the dependency:list
or dependency:tree
in one file for the aggregator, and
2. In the overall project, read both files from modules A and B and have a way to do some comparison and output results (fail the build if comparison gives undesired result).
Any pointers would be helpful.
EDIT:
Clarifying that I need all this to happen during build (mvn clean install
) of the project, every time it builds.