You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by gn...@apache.org on 2026/09/24 12:07:46 UTC
(maven-filtering) branch master updated: fix: copy missing fields in MavenResourcesExecution.copyOf() (#374)
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-filtering.git
The following commit(s) were added to refs/heads/master by this push:
new c83c351 fix: copy missing fields in MavenResourcesExecution.copyOf() (#374)
c83c351 is described below
commit c83c35132fdaf809ba0a648d37e365e517911147
Author: Elliotte Rusty Harold <el...@users.noreply.github.com>
AuthorDate: Thu Sep 24 12:07:40 2026 +0000
fix: copy missing fields in MavenResourcesExecution.copyOf() (#374)
- Copy `delimiters`, `flatten`, `propertiesEncoding`, and `interpolatorCustomizer` fields that were introduced after the 2019 copyOf fix and never backfilled
- Add tests verifying all four fields survive a copyOf() round-trip
Fixes #350
---
.../shared/filtering/MavenResourcesExecution.java | 5 ++
.../filtering/MavenResourcesExecutionTest.java | 96 ++++++++++++++++++++++
2 files changed, 101 insertions(+)
diff --git a/src/main/java/org/apache/maven/shared/filtering/MavenResourcesExecution.java b/src/main/java/org/apache/maven/shared/filtering/MavenResourcesExecution.java
index 478091e..c360829 100644
--- a/src/main/java/org/apache/maven/shared/filtering/MavenResourcesExecution.java
+++ b/src/main/java/org/apache/maven/shared/filtering/MavenResourcesExecution.java
@@ -21,6 +21,7 @@ package org.apache.maven.shared.filtering;
import java.io.Reader;
import java.nio.file.Path;
import java.util.ArrayList;
+import java.util.LinkedHashSet;
import java.util.List;
import org.apache.maven.api.Project;
@@ -446,6 +447,10 @@ public class MavenResourcesExecution extends AbstractMavenFilteringRequest {
mre.setUseDefaultFilterWrappers(this.isUseDefaultFilterWrappers());
mre.setAddDefaultExcludes(this.isAddDefaultExcludes());
mre.setSupportMultiLineFiltering(this.isSupportMultiLineFiltering());
+ mre.setFlatten(this.isFlatten());
+ mre.setPropertiesEncoding(this.getPropertiesEncoding());
+ mre.setDelimiters(new LinkedHashSet<>(this.getDelimiters()));
+ mre.setInterpolatorCustomizer(this.getInterpolatorCustomizer());
return mre;
}
diff --git a/src/test/java/org/apache/maven/shared/filtering/MavenResourcesExecutionTest.java b/src/test/java/org/apache/maven/shared/filtering/MavenResourcesExecutionTest.java
new file mode 100644
index 0000000..07c5326
--- /dev/null
+++ b/src/test/java/org/apache/maven/shared/filtering/MavenResourcesExecutionTest.java
@@ -0,0 +1,96 @@
+/*
+ * 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.shared.filtering;
+
+import java.util.LinkedHashSet;
+import java.util.function.Consumer;
+
+import org.codehaus.plexus.interpolation.Interpolator;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+/**
+ * Tests for {@link MavenResourcesExecution#copyOf()}.
+ */
+class MavenResourcesExecutionTest {
+
+ @Test
+ void copyOfShouldPreserveFlatten() {
+ MavenResourcesExecution original = new MavenResourcesExecution();
+ original.setFlatten(true);
+
+ MavenResourcesExecution copy = original.copyOf();
+
+ Assertions.assertTrue(copy.isFlatten(), "flatten should be copied");
+ }
+
+ @Test
+ void copyOfShouldPreservePropertiesEncoding() {
+ MavenResourcesExecution original = new MavenResourcesExecution();
+ original.setPropertiesEncoding("ISO-8859-1");
+
+ MavenResourcesExecution copy = original.copyOf();
+
+ Assertions.assertEquals("ISO-8859-1", copy.getPropertiesEncoding());
+ }
+
+ @Test
+ void copyOfShouldPreserveDelimiters() {
+ MavenResourcesExecution original = new MavenResourcesExecution();
+ LinkedHashSet<String> delimiters = new LinkedHashSet<>();
+ delimiters.add("@{*@}");
+ delimiters.add("${*}");
+ original.setDelimiters(delimiters);
+
+ MavenResourcesExecution copy = original.copyOf();
+
+ Assertions.assertEquals(original.getDelimiters(), copy.getDelimiters());
+ }
+
+ @Test
+ void copyOfShouldPreserveInterpolatorCustomizer() {
+ Consumer<Interpolator> customizer = interpolator -> {};
+ MavenResourcesExecution original = new MavenResourcesExecution();
+ original.setInterpolatorCustomizer(customizer);
+
+ MavenResourcesExecution copy = original.copyOf();
+
+ Assertions.assertSame(customizer, copy.getInterpolatorCustomizer());
+ }
+
+ @Test
+ void copyOfShouldCopyAllFourMissingFields() {
+ Consumer<Interpolator> customizer = interpolator -> {};
+ LinkedHashSet<String> delimiters = new LinkedHashSet<>();
+ delimiters.add("@{*@}");
+
+ MavenResourcesExecution original = new MavenResourcesExecution();
+ original.setFlatten(true);
+ original.setPropertiesEncoding("UTF-16");
+ original.setDelimiters(delimiters);
+ original.setInterpolatorCustomizer(customizer);
+
+ MavenResourcesExecution copy = original.copyOf();
+
+ Assertions.assertTrue(copy.isFlatten());
+ Assertions.assertEquals("UTF-16", copy.getPropertiesEncoding());
+ Assertions.assertEquals(delimiters, copy.getDelimiters());
+ Assertions.assertSame(customizer, copy.getInterpolatorCustomizer());
+ }
+}