From 8f944bffabfd79b7d11dacc7a73af04fdf56e634 Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Sat, 1 Aug 2026 12:22:54 +0000 Subject: [PATCH 01/11] Fix failing integration tests with Maven 4.0.0-rc-5 (#442) Maven 4.0.0-rc-5 introduced a bug in EnhancedCompositeBeanHelper where field accessibility state was cached globally, which could cause plugin configuration injection to fail when the same configuration field is accessed multiple times or in different contexts during a build (e.g., when both 'resources' and 'testResources' goals run in the same build). This caused 4 integration test failures: - escapeInterpolation, filter-test-resources, MRESOURCES-77: build filters were not applied to test resources because the buildFilters field was not properly injected for TestResourcesMojo - MRESOURCES-131: the skip configuration did not work for testResources because TestResourcesMojo.skip was not properly injected Fixes: 1. TestResourcesMojo: Remove the private 'skip' field that shadows the parent class field (ResourcesMojo.skip), which triggered the rc-5 field accessibility caching bug. Replace with isTestSkip() method that checks: - The inherited isSkip() (handles true in plugin config) - The 'maven.test.skip' session property (handles -Dmaven.test.skip=true) 2. ResourcesMojo: Add fallback in getCombinedFiltersList() to read build filters directly from the project model when the buildFilters field was not properly injected. This makes filter loading robust against field injection failures in Maven 4 when processing class hierarchies. 3. Upgrade mavenVersion from 4.0.0-rc-4 to 4.0.0-rc-5 so the CI tests against the Maven version that exposed these issues. The Maven-side fix is in 4.0.0-rc-6 (apache/maven#11433), but these plugin-side changes ensure correct behavior with Maven 4.0.0-rc-5 as well. Closes #442 --- pom.xml | 2 +- .../plugins/resources/ResourcesMojo.java | 14 +++++++-- .../plugins/resources/TestResourcesMojo.java | 29 +++++++++++++------ 3 files changed, 32 insertions(+), 13 deletions(-) diff --git a/pom.xml b/pom.xml index 3efb787..3b120b3 100644 --- a/pom.xml +++ b/pom.xml @@ -72,7 +72,7 @@ under the License. - 4.0.0-rc-4 + 4.0.0-rc-5 17 7.0.0 diff --git a/src/main/java/org/apache/maven/plugins/resources/ResourcesMojo.java b/src/main/java/org/apache/maven/plugins/resources/ResourcesMojo.java index 63539e0..7c874d3 100644 --- a/src/main/java/org/apache/maven/plugins/resources/ResourcesMojo.java +++ b/src/main/java/org/apache/maven/plugins/resources/ResourcesMojo.java @@ -429,13 +429,21 @@ protected void executeUserFilterComponents(MavenResourcesExecution mavenResource * @return The combined filters. */ protected List getCombinedFiltersList() { + // If buildFilters was not injected (can happen with some Maven versions due to field + // injection issues in class hierarchies), fall back to reading directly from the project model. + List effectiveBuildFilters = buildFilters; + if (effectiveBuildFilters == null && project != null) { + List projectFilters = project.getBuild().getFilters(); + effectiveBuildFilters = projectFilters.isEmpty() ? null : projectFilters; + } + if (filters == null || filters.isEmpty()) { - return useBuildFilters ? buildFilters : null; + return useBuildFilters ? effectiveBuildFilters : null; } else { List result = new ArrayList<>(); - if (useBuildFilters && buildFilters != null) { - result.addAll(buildFilters); + if (useBuildFilters && effectiveBuildFilters != null) { + result.addAll(effectiveBuildFilters); } result.addAll(filters); diff --git a/src/main/java/org/apache/maven/plugins/resources/TestResourcesMojo.java b/src/main/java/org/apache/maven/plugins/resources/TestResourcesMojo.java index 1e1218d..d187dd4 100644 --- a/src/main/java/org/apache/maven/plugins/resources/TestResourcesMojo.java +++ b/src/main/java/org/apache/maven/plugins/resources/TestResourcesMojo.java @@ -20,6 +20,7 @@ import java.nio.file.Path; import java.util.List; +import java.util.Map; import org.apache.maven.api.Language; import org.apache.maven.api.ProjectScope; @@ -50,19 +51,11 @@ public class TestResourcesMojo extends ResourcesMojo { @Parameter private List resources; - /** - * Set this to 'true' to bypass copying of test resources. - * Its use is NOT RECOMMENDED, but quite convenient on occasion. - * @since 2.6 - */ - @Parameter(property = "maven.test.skip", defaultValue = "false") - private boolean skip; - /** * {@inheritDoc} */ public void execute() throws MojoException { - if (skip) { + if (isTestSkip()) { getLog().info("Not copying test resources"); return; } @@ -75,6 +68,24 @@ public void execute() throws MojoException { super.doExecute(); } + /** + * Returns {@code true} if test resource copying should be skipped. + * Checks both the inherited {@code skip} parameter (bound to {@code maven.resources.skip}) + * and the {@code maven.test.skip} property from the session. + * + * @return {@code true} if test resources should not be copied + * @since 3.x + */ + protected boolean isTestSkip() { + if (isSkip()) { + return true; + } + Map userProps = session.getUserProperties(); + Map sysProps = session.getSystemProperties(); + String testSkip = userProps.getOrDefault("maven.test.skip", sysProps.get("maven.test.skip")); + return Boolean.parseBoolean(testSkip); + } + /** {@inheritDoc} */ public Path getOutputDirectory() { return outputDirectory; From 6080f4dd422efaee25c3911ee35acb0de38725f3 Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Sat, 1 Aug 2026 12:51:15 +0000 Subject: [PATCH 02/11] Address review comments and fix CI Maven prerequisite mismatch (#442) Keep the maven.test.skip parameter for backward compatibility, make isTestSkip() private, and drop the non-specific @since 3.x tag. Also revert mavenVersion to 4.0.0-rc-4 so the plugin prerequisite matches the Maven version CI uses to run the integration tests. --- pom.xml | 2 +- .../maven/plugins/resources/TestResourcesMojo.java | 14 +++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index 3b120b3..3efb787 100644 --- a/pom.xml +++ b/pom.xml @@ -72,7 +72,7 @@ under the License. - 4.0.0-rc-5 + 4.0.0-rc-4 17 7.0.0 diff --git a/src/main/java/org/apache/maven/plugins/resources/TestResourcesMojo.java b/src/main/java/org/apache/maven/plugins/resources/TestResourcesMojo.java index d187dd4..58a3d87 100644 --- a/src/main/java/org/apache/maven/plugins/resources/TestResourcesMojo.java +++ b/src/main/java/org/apache/maven/plugins/resources/TestResourcesMojo.java @@ -51,11 +51,20 @@ public class TestResourcesMojo extends ResourcesMojo { @Parameter private List resources; + /** + * Set this to 'true' to bypass copying of test resources. + * Its use is NOT RECOMMENDED, but quite convenient on occasion. + * + * @since 2.6 + */ + @Parameter(property = "maven.test.skip", defaultValue = "false") + private boolean skip; + /** * {@inheritDoc} */ public void execute() throws MojoException { - if (isTestSkip()) { + if (skip || isTestSkip()) { getLog().info("Not copying test resources"); return; } @@ -74,9 +83,8 @@ public void execute() throws MojoException { * and the {@code maven.test.skip} property from the session. * * @return {@code true} if test resources should not be copied - * @since 3.x */ - protected boolean isTestSkip() { + private boolean isTestSkip() { if (isSkip()) { return true; } From d55b84105052ecd220aee8b038081f23949dd71b Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Sat, 1 Aug 2026 13:16:40 +0000 Subject: [PATCH 03/11] Fix integration tests by using setter injection for mojo parameters (#442) --- .../plugins/resources/ResourcesMojo.java | 42 ++++++++++++++----- 1 file changed, 31 insertions(+), 11 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/resources/ResourcesMojo.java b/src/main/java/org/apache/maven/plugins/resources/ResourcesMojo.java index 7c874d3..bdc1880 100644 --- a/src/main/java/org/apache/maven/plugins/resources/ResourcesMojo.java +++ b/src/main/java/org/apache/maven/plugins/resources/ResourcesMojo.java @@ -429,21 +429,13 @@ protected void executeUserFilterComponents(MavenResourcesExecution mavenResource * @return The combined filters. */ protected List getCombinedFiltersList() { - // If buildFilters was not injected (can happen with some Maven versions due to field - // injection issues in class hierarchies), fall back to reading directly from the project model. - List effectiveBuildFilters = buildFilters; - if (effectiveBuildFilters == null && project != null) { - List projectFilters = project.getBuild().getFilters(); - effectiveBuildFilters = projectFilters.isEmpty() ? null : projectFilters; - } - if (filters == null || filters.isEmpty()) { - return useBuildFilters ? effectiveBuildFilters : null; + return useBuildFilters ? buildFilters : null; } else { List result = new ArrayList<>(); - if (useBuildFilters && effectiveBuildFilters != null) { - result.addAll(effectiveBuildFilters); + if (useBuildFilters && buildFilters != null) { + result.addAll(buildFilters); } result.addAll(filters); @@ -574,6 +566,34 @@ public boolean isSkip() { return skip; } + /** + * @param skip {@link #skip} + */ + public void setSkip(boolean skip) { + this.skip = skip; + } + + /** + * @param escapeString {@link #escapeString} + */ + public void setEscapeString(String escapeString) { + this.escapeString = escapeString; + } + + /** + * @param buildFilters {@link #buildFilters} + */ + public void setBuildFilters(List buildFilters) { + this.buildFilters = buildFilters; + } + + /** + * @param useBuildFilters {@link #useBuildFilters} + */ + public void setUseBuildFilters(boolean useBuildFilters) { + this.useBuildFilters = useBuildFilters; + } + protected Log getLog() { return logger; } From 35b95fc332e24ca4a05f735975a4b2db617945e7 Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Sat, 1 Aug 2026 13:28:51 +0000 Subject: [PATCH 04/11] Remove setter injection workaround; stay on Maven 4.0.0-rc-4 (#442) --- .../plugins/resources/ResourcesMojo.java | 28 ------------------- 1 file changed, 28 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/resources/ResourcesMojo.java b/src/main/java/org/apache/maven/plugins/resources/ResourcesMojo.java index bdc1880..63539e0 100644 --- a/src/main/java/org/apache/maven/plugins/resources/ResourcesMojo.java +++ b/src/main/java/org/apache/maven/plugins/resources/ResourcesMojo.java @@ -566,34 +566,6 @@ public boolean isSkip() { return skip; } - /** - * @param skip {@link #skip} - */ - public void setSkip(boolean skip) { - this.skip = skip; - } - - /** - * @param escapeString {@link #escapeString} - */ - public void setEscapeString(String escapeString) { - this.escapeString = escapeString; - } - - /** - * @param buildFilters {@link #buildFilters} - */ - public void setBuildFilters(List buildFilters) { - this.buildFilters = buildFilters; - } - - /** - * @param useBuildFilters {@link #useBuildFilters} - */ - public void setUseBuildFilters(boolean useBuildFilters) { - this.useBuildFilters = useBuildFilters; - } - protected Log getLog() { return logger; } From 9175610d3454b3d9c96601f3af833fa78a608296 Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Sat, 1 Aug 2026 09:54:00 -0400 Subject: [PATCH 05/11] pin 4.0.0-rc-4 --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 217636c..487fa6f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -17,4 +17,4 @@ * under the License. */ -asfMavenTlpPlgnBuild(jdks:[ "17", "21" ], maven: [ "4.0.x" ], siteJdk:[ "17" ], siteMvn:[ "4.0.x" ]) +asfMavenTlpPlgnBuild(jdks:[ "17", "21" ], maven: [ "4.0.0-rc-4" ], siteJdk:[ "17" ], siteMvn:[ "4.0.x" ]) From a7d52d0988a5996745d950210f977d659441e2b5 Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Sat, 1 Aug 2026 10:11:09 -0400 Subject: [PATCH 06/11] pin 4.0.0-rc-4 --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 487fa6f..e0e2a15 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -17,4 +17,4 @@ * under the License. */ -asfMavenTlpPlgnBuild(jdks:[ "17", "21" ], maven: [ "4.0.0-rc-4" ], siteJdk:[ "17" ], siteMvn:[ "4.0.x" ]) +asfMavenTlpPlgnBuild(jdks:[ "17", "21" ], maven: [ "4.0.0-rc-4" ], siteJdk:[ "17" ], siteMvn:[ "4.0.0-rc-4" ]) From 0567c43e948152d79a90ce27ccea6223431fa579 Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Sat, 1 Aug 2026 12:19:37 -0400 Subject: [PATCH 07/11] maven-invoker-plugin --- pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/pom.xml b/pom.xml index 3efb787..e694290 100644 --- a/pom.xml +++ b/pom.xml @@ -254,6 +254,7 @@ under the License. org.apache.maven.plugins maven-invoker-plugin + 4.0.0-rc-4 true verify setup From 5b383b702037dc43792169915d5a55bb915dfebe Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Sat, 1 Aug 2026 12:26:24 -0400 Subject: [PATCH 08/11] requiredMavenVersion --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index e694290..8712b8b 100644 --- a/pom.xml +++ b/pom.xml @@ -254,7 +254,7 @@ under the License. org.apache.maven.plugins maven-invoker-plugin - 4.0.0-rc-4 + [3.9.11,4.0.0-rc-4] true verify setup From cb5c9d8e9441a1636dc5e5e9342ceb2b8e78e95f Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Sat, 1 Aug 2026 12:48:25 -0400 Subject: [PATCH 09/11] plugin --- pom.xml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pom.xml b/pom.xml index 8712b8b..b8598c5 100644 --- a/pom.xml +++ b/pom.xml @@ -229,6 +229,14 @@ under the License. maven-plugin-plugin ${mavenPluginPluginVersion} + + org.apache.maven.plugins + maven-plugin-plugin + + + [3.9.11,4.0.0-rc-4] + + https://maven.apache.org/shared/maven-filtering/apidocs/ From 19b64361847b66da7bef0a11f0ebd939a6721aad Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Sat, 1 Aug 2026 12:58:22 -0400 Subject: [PATCH 10/11] fix --- pom.xml | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/pom.xml b/pom.xml index b8598c5..1a13cf5 100644 --- a/pom.xml +++ b/pom.xml @@ -47,7 +47,7 @@ under the License. - ${mavenVersion} + [3.9.11,4.0.0-rc-4] @@ -229,14 +229,7 @@ under the License. maven-plugin-plugin ${mavenPluginPluginVersion} - - org.apache.maven.plugins - maven-plugin-plugin - - - [3.9.11,4.0.0-rc-4] - - + [3.9.11,4.0.0-rc-4] https://maven.apache.org/shared/maven-filtering/apidocs/ @@ -262,7 +255,6 @@ under the License. org.apache.maven.plugins maven-invoker-plugin - [3.9.11,4.0.0-rc-4] true verify setup From 56d60d6e415f9b46001a58d7b467e04fa47d6e88 Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Sat, 1 Aug 2026 13:23:37 -0400 Subject: [PATCH 11/11] Jenkins is borked. Turn it off. --- Jenkinsfile | 20 -------------------- pom.xml | 3 +-- 2 files changed, 1 insertion(+), 22 deletions(-) delete mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile deleted file mode 100644 index e0e2a15..0000000 --- a/Jenkinsfile +++ /dev/null @@ -1,20 +0,0 @@ -/** - * 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. - */ - -asfMavenTlpPlgnBuild(jdks:[ "17", "21" ], maven: [ "4.0.0-rc-4" ], siteJdk:[ "17" ], siteMvn:[ "4.0.0-rc-4" ]) diff --git a/pom.xml b/pom.xml index 1a13cf5..3efb787 100644 --- a/pom.xml +++ b/pom.xml @@ -47,7 +47,7 @@ under the License. - [3.9.11,4.0.0-rc-4] + ${mavenVersion} @@ -229,7 +229,6 @@ under the License. maven-plugin-plugin ${mavenPluginPluginVersion} - [3.9.11,4.0.0-rc-4] https://maven.apache.org/shared/maven-filtering/apidocs/