Maven enforcer plugin has many usages when it comes to managing dependencies. The one I am going to give an example of now, has to do with banning certain dependencies.
The use case is something like this — you have a multi-module maven project. As time has grown your repo has evolved and now you have the need to deprecate a module. You want to make sure that when someone is building using a module — they don’t use the older implementation. The way I have managed it is, using mvn enforcer plugin.
<message>Module artefact1 has been deprecated. Please use the new-artefact1 module instead</message>
<message>Module artefact2 has been deprecated. Please use the newartefact2 module instead</message>
After adding this enforcer rule to the parent pom, no one will be able to add the module
artefact1 as a dependency in their new modules. They will received the message with a build failure informing them that they should use
new-artefact module instead.