The maven-enforcer-plugin (and it’s various extensions) are really useful if you want to enforce various build rules such as :
- Make sure the maven build is using minimum required Java and Maven versions.
- Build is not referring to snapshot dependencies
- No Duplicate classes in your project dependencies (see screenshot below of what it reports when it finds duplicates)
- Ban certain imports (e.g. java.util.Vector, java.util.Date etc) being used in your build.
Here is an example project to show above checks in action.
Output of BanDuplicateClasses check if it detects duplicate classes.
Output of RestrictImports if finds usage of Banned Import (example: java.util.Vector).