Is there a way e.g. a Maven plug in that can take a list of unwanted/black listed dependencies (direct and transitive) and fails the build if it detects one of listed dependencies?
In my project we strictly want to get rid of Apache Commons Logging and replace it with the SLF4J JCL Bridge. I am aware that we have to exclude the unwanted deps ourselfs but I would like to have the build failed if someone adds a dependency that brings in blacklisted dependency.
Yes, the enforcer plugin supports this with its bannedDependencies rule.
You can ban some dependencies using the
maven-enforcer-plugin
.Here is their example with updates for your exclusion of Apache Commons Logging.
The output when running
mvn install
will be:It all ends with a
BUILD FAILURE
.