I agree this behavior is unexpected. But it's different for properties! So a workaround here is to have a unique property for each check you want to skip, so that you can override the property by command line rather than overriding the <skip> configuration directly. Then you can have a single way to set all these properties. In my company's parent pom we have a profile that can be activated like `mvn install -P quick` to skip tests and checks:
<profile> <id>quick</id> <properties> <checkstyle.skip>true</checkstyle.skip> <duplicate-finder.skip>true</duplicate-finder.skip> <enforcer.skip>true</enforcer.skip> <skipITs>true</skipITs> <skipTests>true</skipTests> </properties> </profile> So if I want to still run the enforcer plugin, I can do this: `mvn install -P quick -Denforcer.skip=false`. If you want to keep using a property rather than a profile, I assume you could have the specific property for each check reference your main property by default, like: <properties> <skip.our.enforcer>${skipChecks}</skip.our.enforcer> </properties> [...] <skip>${skip.our.enforcer}</skip> But I haven't tested it. On Mon, Sep 14, 2020 at 9:11 AM Andreas Sewe <andreas_s...@buildingblobs.com> wrote: > Hi, > > I am currently sprinkling <configuration> child elements like the > following through my (parent) POMs for enforcer:enforce, tidy:check and > checkstyle:check <executions>: > > <skip>${skipChecks}</skip> > > This allows me to skip all kinds of checks with a simple > -DskipChecks=true (or even -DskipChecks), just like I am used to for > tests with -DskipTests. > > Unfortunately, I cannot selectively override this, as the following > doesn't work: > > mvn install -DskipChecks -Denforcer.skip=false > > The above command still uses the <skip>${skipChecks}</skip> (with > skipChecks=true). > > Further experimentation led me to believe that *any* explicit pom.xml > <configuration> cannot be overridden by a property expression given on > the command line. > > This was very surprising, as I would have expected Maven to follow a > "command line takes precedence over configuration file" approach like > other tools -- but apparently it doesn't (at least in Maven 3.3.9 and > 3.6.3) and thus violates the Principle of Least Astonishment (for one of > its users anyway). > > In particular, Maven's handling of property expressions means that > having no <skip> element and making the default explicit behave > differently; a <configuration> element like this can never be overridden > on the command-line: > > <skip>false</skip> > > I wonder why it was designed that way? > > Or should this be considered a bug? > > Best wishes, > > Andreas > >