[MNG-8694] Fix version interpolation and ternary operator#2272
[MNG-8694] Fix version interpolation and ternary operator#2272gnodet merged 7 commits intoapache:masterfrom
Conversation
gnodet
left a comment
There was a problem hiding this comment.
I don't think the behavior is complete.
It could be solved by a loop, but preferably by using the DefaultInterpolator service.
impl/maven-core/src/test/resources/projects/pom-parent-version-from-nested-properties/pom.xml
Outdated
Show resolved
Hide resolved
impl/maven-impl/src/main/java/org/apache/maven/impl/model/DefaultModelBuilder.java
Outdated
Show resolved
Hide resolved
|
@gnodet Removed unused regex as well, can you approve again? |
|
I still think this only partially address the use case from MNG-8694, so IMHO we'd need to extend the test to support a similar use case. Probably not using a profile, since it won't work, but using a value such as |
|
@gnodet Test case extended |
Thx, I slightly modified it as one of the problem was the generation of an empty string when This PR now fixes the ternary operator to support expressions such as The actual solution for the original use case is to use |
When processing ternary expressions like ${release:+${foo}:-${bar}} or ${versionCore}${release:+-DEVELOPER}, the DefaultInterpolator was incorrectly continuing to process subsequent operators after a decision had been made on the first operator.
This fix adds a break statement after each successful operator evaluation to stop processing any remaining operators once a decision has been made, ensuring that:
1. When 'release' is true and 'foo' is empty, correctly evaluates to an empty string
2. When 'release' is true, correctly evaluates to just
Added test cases to verify both scenarios.
|
Resolve #9611 |
Fix for https://issues.apache.org/jira/browse/MNG-8694
@slawekjaranowski as mentioned today on jug challenge accepted!