This is an automated email from the ASF dual-hosted git repository.

gnodet pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven.git


The following commit(s) were added to refs/heads/master by this push:
     new 5426073a36 [MNG-3558] Ensure properties can be escaped (#2206)
5426073a36 is described below

commit 5426073a3655278e58f8a4178faae335b1544fc0
Author: Guillaume Nodet <gno...@gmail.com>
AuthorDate: Wed Apr 2 21:54:12 2025 +0200

    [MNG-3558] Ensure properties can be escaped (#2206)
---
 .../it/MavenITmng3558PropertyEscapingTest.java     | 62 +++++++++++++++
 .../org/apache/maven/it/TestSuiteOrdering.java     |  1 +
 .../resources/mng-3558-property-escaping/pom.xml   | 88 ++++++++++++++++++++++
 3 files changed, 151 insertions(+)

diff --git 
a/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng3558PropertyEscapingTest.java
 
b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng3558PropertyEscapingTest.java
new file mode 100644
index 0000000000..3b1aac67df
--- /dev/null
+++ 
b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng3558PropertyEscapingTest.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.maven.it;
+
+import java.io.File;
+import java.util.Properties;
+
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+/**
+ * This is a test case for <a 
href="https://issues.apache.org/jira/browse/MNG-3558";>MNG-3558</a>.
+ *
+ * Verifies that property references can be properly escaped in both model 
properties
+ * and plugin configuration using backslash.
+ */
+class MavenITmng3558PropertyEscapingTest extends 
AbstractMavenIntegrationTestCase {
+    MavenITmng3558PropertyEscapingTest() {
+        super("[4.0.0-beta-5,)");
+    }
+
+    @Test
+    public void testPropertyEscaping() throws Exception {
+        File testDir = extractResources("/mng-3558-property-escaping");
+
+        Verifier verifier = newVerifier(testDir.getAbsolutePath());
+        verifier.setAutoclean(false);
+        verifier.deleteDirectory("target");
+        verifier.addCliArgument("validate");
+        verifier.execute();
+        verifier.verifyErrorFreeLog();
+
+        // Verify model properties
+        Properties modelProps = 
verifier.loadProperties("target/property-values.properties");
+        assertEquals("${test.value}", 
modelProps.getProperty("project.properties.escaped.property"));
+        assertEquals("prefix-${test.value}-suffix", 
modelProps.getProperty("project.properties.escaped.with.context"));
+        assertEquals("interpolated-value", 
modelProps.getProperty("project.properties.normal.property"));
+
+        // Verify plugin configuration
+        Properties configProps = 
verifier.loadProperties("target/config-values.properties");
+        assertEquals("${test.value}", 
configProps.getProperty("mapParam.param"));
+        assertEquals("prefix-${test.value}-suffix", 
configProps.getProperty("mapParam.paramWithContext"));
+        assertEquals("interpolated-value", 
configProps.getProperty("mapParam.normalParam"));
+    }
+}
diff --git 
a/its/core-it-suite/src/test/java/org/apache/maven/it/TestSuiteOrdering.java 
b/its/core-it-suite/src/test/java/org/apache/maven/it/TestSuiteOrdering.java
index c2f0c8fda8..470a7a9f56 100644
--- a/its/core-it-suite/src/test/java/org/apache/maven/it/TestSuiteOrdering.java
+++ b/its/core-it-suite/src/test/java/org/apache/maven/it/TestSuiteOrdering.java
@@ -101,6 +101,7 @@ public TestSuiteOrdering() {
          * the tests are to finishing. Newer tests are also more likely to 
fail, so this is
          * a fail fast technique as well.
          */
+        suite.addTestSuite(MavenITmng3558PropertyEscapingTest.class);
         suite.addTestSuite(MavenITmng4559MultipleJvmArgsTest.class);
         suite.addTestSuite(MavenITmng4559SpacesInJvmOptsTest.class);
         suite.addTestSuite(MavenITmng8598JvmConfigSubstitutionTest.class);
diff --git 
a/its/core-it-suite/src/test/resources/mng-3558-property-escaping/pom.xml 
b/its/core-it-suite/src/test/resources/mng-3558-property-escaping/pom.xml
new file mode 100644
index 0000000000..1d90c56e5f
--- /dev/null
+++ b/its/core-it-suite/src/test/resources/mng-3558-property-escaping/pom.xml
@@ -0,0 +1,88 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";>
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.maven.its.mng3558</groupId>
+  <artifactId>test</artifactId>
+  <version>1.0</version>
+
+  <name>Maven Integration Test :: MNG-3558</name>
+  <description>Verify that property references can be escaped in both model 
properties and plugin configuration.</description>
+
+  <properties>
+    <!-- Value that should be interpolated -->
+    <test.value>interpolated-value</test.value>
+
+    <!-- Escaped properties -->
+    <escaped.property>$\{test.value\}</escaped.property>
+    <escaped.with.context>prefix-$\{test.value\}-suffix</escaped.with.context>
+
+    <!-- Regular interpolation for comparison -->
+    <normal.property>${test.value}</normal.property>
+  </properties>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.its.plugins</groupId>
+        <artifactId>maven-it-plugin-expression</artifactId>
+        <version>2.1-SNAPSHOT</version>
+        <executions>
+          <execution>
+            <id>test</id>
+            <goals>
+              <goal>eval</goal>
+            </goals>
+            <phase>validate</phase>
+            <configuration>
+              <outputFile>target/property-values.properties</outputFile>
+              <expressions>
+                <expression>project/properties</expression>
+              </expressions>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.its.plugins</groupId>
+        <artifactId>maven-it-plugin-configuration</artifactId>
+        <version>2.1-SNAPSHOT</version>
+        <executions>
+          <execution>
+            <id>config</id>
+            <goals>
+              <goal>config</goal>
+            </goals>
+            <phase>validate</phase>
+            <configuration>
+              <propertiesFile>target/config-values.properties</propertiesFile>
+              <mapParam>
+                <param>$$\{test.value\}</param>
+                
<paramWithContext>prefix-$$\{test.value\}-suffix</paramWithContext>
+                <normalParam>${test.value}</normalParam>
+              </mapParam>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>

Reply via email to