From ab5c8d516e84a45be144d0a85feb7011563519fd Mon Sep 17 00:00:00 2001 From: Mikhail Kolesnikov Date: Wed, 29 Nov 2023 20:20:32 +0300 Subject: [PATCH] MRELEASE-1109 patch JDomModel --- .../maven/shared/release/phase/AbstractRewritePomsPhase.java | 4 ++-- .../maven/shared/release/transform/jdom2/JDomModel.java | 2 +- .../expected-pom.xml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractRewritePomsPhase.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractRewritePomsPhase.java index 76747c56..71972df1 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractRewritePomsPhase.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractRewritePomsPhase.java @@ -96,7 +96,7 @@ public abstract class AbstractRewritePomsPhase extends AbstractReleasePhase impl * Regular expression pattern matching Maven expressions (i.e. references to Maven properties). * The first group selects the property name the expression refers to. */ - private static final Pattern EXPRESSION_PATTERN = Pattern.compile("\\$\\{(.+)\\}"); + private static final Pattern EXPRESSION_PATTERN = Pattern.compile("\\$\\{(.+?)\\}"); /** * All Maven properties allowed to be referenced in parent versions via expressions @@ -462,7 +462,7 @@ private void rewriteVersion( */ public static String extractPropertyFromExpression(String expression) { Matcher matcher = EXPRESSION_PATTERN.matcher(expression); - if (!matcher.matches()) { + if (!matcher.find()) { return null; } return matcher.group(1); diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/transform/jdom2/JDomModel.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/transform/jdom2/JDomModel.java index 6198ee73..20d972bd 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/transform/jdom2/JDomModel.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/transform/jdom2/JDomModel.java @@ -198,7 +198,7 @@ public void setVersion(String version) { AbstractRewritePomsPhase.extractPropertyFromExpression(versionElement.getTextNormalize()); Properties properties = getProperties(); if (properties != null) { - properties.computeIfPresent(ciFriendlyPropertyName, (k, v) -> version); + properties.setProperty(ciFriendlyPropertyName, version); } } else { JDomUtils.rewriteValue(versionElement, version); diff --git a/maven-release-manager/src/test/resources/projects/rewrite-for-release/pom-with-parent-and-cifriendly-expressions/expected-pom.xml b/maven-release-manager/src/test/resources/projects/rewrite-for-release/pom-with-parent-and-cifriendly-expressions/expected-pom.xml index c7504063..b4326d54 100644 --- a/maven-release-manager/src/test/resources/projects/rewrite-for-release/pom-with-parent-and-cifriendly-expressions/expected-pom.xml +++ b/maven-release-manager/src/test/resources/projects/rewrite-for-release/pom-with-parent-and-cifriendly-expressions/expected-pom.xml @@ -30,7 +30,7 @@ - 1.0-SNAPSHOT + 1.0