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
signature.asc
Description: OpenPGP digital signature
