I am trying to setup the enforcer plugin for maven to enforce a minimum Java version. However, whenever I try to run mvn enforcer:enforce
, I get:
In my case the problem was that I was putting the enforcer configuration inside the build part of a Maven profile which was not being built when I ran mvn validate
. A simple mvn validate -P correctProfile
fixed it for me. In the end I put it into the parent project of a multi-module application, set the transitive search of bytecode enforcer rule to true:
and verified that an incorrect dependency in a child project indeed causes a build failure.