Uploaded image for project: 'Maven Enforcer Plugin'
  1. Maven Enforcer Plugin
  2. MENFORCER-363

Unexpected result from requireProperty with regex when the property is not fully resolved



    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 3.0.0-M3
    • Fix Version/s: None
    • Component/s: Standard Rules
    • Labels:


      I was looking for a way to verify a property is defined and is fully resolved. When it cannot resolve a placeholder, Maven usually leave it unchanged. So if property "unknown" is not defined, "<foo>pre-${unknown}</foo>" would not fully resolve and would left asis.

      With this in mind, I thought I could use the "requireProperty" with a regex looking for "$" to check if a property is fully resolved or not. 

      Consider the following example:



      Here is what the execution reports:

      [WARNING] Rule 0: org.apache.maven.plugins.enforcer.RequireProperty failed with message:
      Property "foo" is required for this build.


      For the first rule, since "foo" refers to an unknown property, I can understand it is "not defined" and that the rule complains about it.

      However, I would expect the second rule to fail as well. Let's change its regex to "[0-9]+" to see what happens:

      [WARNING] Rule 1: org.apache.maven.plugins.enforcer.RequireProperty failed with message:
      Property "bar" evaluates to "prenull".  This does not match the regular expression "[0-9]+" 

      As we can see, the placeholder "${unknown}" has been resolved into "null" - reason why the rule didn't fail initially...


      IMHO this behaviour is not intuitive since Maven's standard behaviour is to leave placeholders unchanged when they cannot be resolved.






            • Assignee:
              brenuart Bertrand Renuart
            • Votes:
              0 Vote for this issue
              1 Start watching this issue


              • Created: