Use mvn dependency:analyze
to show you whether there are dependencies in your pom that you don't need (it may also identify some that you have missed, add -DoutputXML=true
to show the missing entries).
Use mvn dependency:tree
to show you the dependencies currently in use by your project and where Maven is finding them. Add -Dverbose=true
to show all the duplicates and conflicts.
If a
directly depends on c
(that is if code in a
mentions classes in c
), then the pom should reflect it. If a
only depends directly on b
, then you can safely remove the c
dependency from a
's pom.xml file. The commands above should enable you to determine what is the appropriate next action.
Edit: Okay, you updated your question. Here is how you do it:
- in project
a
, run mvn dependency:tree -Dverbose=true
. This will show you a complete tree of all dependencies considered by Maven for your project.
- Look at the output of step 1 and make a list of all dependencies that are shown at more than one level deep (some of them will probably be duplicates).
- Edit your pom.xml file in whatever editor you like and remove any dependencies that match the list you created in step 2.
Or are you looking for a way to do it automatically? I do not think there is any automated way unless you write one yourself, because what you are trying to do is a BAD IDEA. You are telling people that their objections are "irrelevant" to your question, but the fact is that your question is like asking "How can I use Maven to make it more difficult to use Maven?"
There is no good reason why you would want to do this. If you think there is a good reason, then you must be trying to do it to produce some result. You should ask for help with the desired result, because your plan is a bad one.