Bertrand Renuart created MENFORCER-363:
------------------------------------------

             Summary: Unexpected result from requireProperty with regex when 
the property is not fully resolved
                 Key: MENFORCER-363
                 URL: https://issues.apache.org/jira/browse/MENFORCER-363
             Project: Maven Enforcer Plugin
          Issue Type: Bug
          Components: Standard Rules
    Affects Versions: 3.0.0-M3
            Reporter: Bertrand Renuart


Consider the following example:
{code:java}
<properties>
  <foo>${unknown}</foo>
  <bar>pre${unknown}</bar>
</properties> 

<plugin>
  <artifactId>maven-enforcer-plugin</artifactId>
  <version>3.0.0-M3</version>
  <executions>
    <execution>
      <goals><goal>enforce</goal></goals>
      <configuration>
        <rules>
          <requireProperty>
            <property>foo</property>
            <regex>[a-z]+</regex>
          </requireProperty>
          <requireProperty>
            <property>bar</property>
            <regex>[a-z]+</regex>
          </requireProperty>
        </rules>
...{code}
 

Here is what the execution reports:
{code:java}
[WARNING] Rule 0: org.apache.maven.plugins.enforcer.RequireProperty failed with 
message:
Property "foo" is required for this build.{code}
 

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, for the second rule I would expect "bar" to resolve to "pre${unknown}" 
which obviously does not satisfy the regex. If we change the regex to "[0-9]*", 
the second rule now fails with the following message:
{code:java}
[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]+" {code}
As we can see, the "${unknown}" has been resolved into "null"...

 

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

 

 

 



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to