[MENFORCER-363] Unexpected result from requireProperty with regex when the property is not fully resolved
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 25/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- java
- Domain
- build-system
Research direction
Start with the RequireProperty rule and reproduce the supplied Maven configuration, comparing unresolved properties such as foo and bar. Review the linked MNG-7194 issue because the report identifies it as the cause. Done means unresolved placeholders are handled consistently with Maven's standard behavior and the reported regex checks produce the expected result.
Written by the indexing model from the issue text.
Description
Bertrand Renuart opened MENFORCER-363 and commented
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:
<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>[^$]*</regex>
</requireProperty>
<requireProperty>
<property>bar</property>
<regex>[^$]*</regex>
</requireProperty>
</rules>
...
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.
Affects: 3.0.0-M3
Issue Links:
- MNG-7194 PluginParameterExpressionEvaluator incorrectly interpolates unknown subexpression
("is caused by")
- Dominant language
- Java
- Stars
- 162
- Forks
- 188
- Avg merge
- 1d 9h
- Merged PRs (30d)
- 17
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- No contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from apache/maven-enforcer
-
RequireUpperBoundDeps does not support includes with only groupIdPossibly taken @waterWang claimed this 98 days ago. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
apache/maven-enforcer#998 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 4/5 3-5 days Newbie friendliness 48/100
apache/maven-enforcer#1038 · 1 comment ·
Maintainers usually reply within 1 day
-
New rule: banSplitPackages — detect packages split across modules and artifactsMay be free again @ascheman claimed this 103 days ago, and no pull request is open. Openenhancement
apache/maven-enforcer#997 · 2 comments · 1 assignee ·
Maintainers usually reply within 1 day
-
New rules: enforce Java Module System descriptor policyMay be free again @ascheman claimed this 109 days ago, and no pull request is open. Openenhancement
apache/maven-enforcer#995 · 1 reaction · 1 assignee ·
Maintainers usually reply within 1 day
-
bug
Difficulty 3/5 1-2 days Newbie friendliness 25/100
apache/maven-enforcer#950 ·
Maintainers usually reply within 1 day
All issues in apache/maven-enforcer
Similar issues
-
[Bug] 资源包列表 与 模组/数据包/世界 列表排列顺序不一致Possibly taken @fishdry1000 claimed this 4 days ago. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
AtlasOfLivingAustralia/species-lists#882 ·
Maintainers usually reply within 1 day
-
Type/Bug
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
ballerina-platform/ballerina-library#9458 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
winder/Universal-G-Code-Sender#3242 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
PCL-Community/PCL-CE#3767 ·
Maintainers usually reply within 1 day