From 06f6de43312ee6cab4ec1a194781a61c5db5bdf9 Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Thu, 11 Jul 2024 19:43:40 +0200 Subject: [PATCH] [MRELEASE-1153] Revert parts of MRELEASE-1109 (8dfcb47996320af5e6f0b2d50eac209eeb4c29ce) due to a regression This reverts commit 8dfcb47996320af5e6f0b2d50eac209eeb4c29ce. This closes #224 --- .../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 71972df1..76747c56 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.find()) { + if (!matcher.matches()) { 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 20d972bd..6198ee73 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.setProperty(ciFriendlyPropertyName, version); + properties.computeIfPresent(ciFriendlyPropertyName, (k, v) -> 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 b4326d54..c7504063 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 + 1.0-SNAPSHOT