Use mvn dependency:analyze to show if there are any dependencies in your pump that you don’t need (this can also identify the missing ones, add -DoutputXML=true to show the missing entries).
Use mvn dependency:tree to show the dependencies that your project is currently using and where Maven finds them. Add -Dverbose=true to show all duplicates and conflicts.
If a directly depends on c (that is, if the code in a mentions classes in c ), then pom should reflect it. If a depends directly on b , you can safely remove the dependency c from a pom.xml. The above commands should allow you to determine what is the appropriate next step.
Edit: Ok, you updated your question. Here's how you do it:
- in project
a , run mvn dependency:tree -Dverbose=true . This will show you a complete tree of all the dependencies that Maven reviewed for your project. - Look at the result of step 1 and make a list of all the dependencies that are shown at more than one level (some of them are likely to duplicate).
- Edit the pom.xml file in any editor you like and delete any dependencies that match the list you created in step 2.
Or are you looking for a way to do this automatically? I do not think that there is any automated way if you do not write it yourself, because you are trying to do this BAD IDEA . You tell people that their objections are “not relevant to your question,” but the fact is that your question is: “How can I use Maven to make it more difficult to use Maven?”
There are no good reasons why you would like to do this. If you think that there is a good reason, you should try to do this in order to get some kind of result. You should ask for the desired result for help, because your plan is bad.
Zac thompson
source share