From 5761a448b964dd89c07233ba7111685745c0cb87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Efe=20G=C3=B6kdemir?= Date: Thu, 24 Sep 2026 08:59:39 +0300 Subject: [PATCH 1/4] Skip resource filtering when no resources are configured --- src/it/empty-resources/invoker.properties | 19 ++++++++++ src/it/empty-resources/pom.xml | 36 +++++++++++++++++++ src/it/empty-resources/verify.groovy | 22 ++++++++++++ .../plugins/resources/ResourcesMojo.java | 4 +++ 4 files changed, 81 insertions(+) create mode 100644 src/it/empty-resources/invoker.properties create mode 100644 src/it/empty-resources/pom.xml create mode 100644 src/it/empty-resources/verify.groovy diff --git a/src/it/empty-resources/invoker.properties b/src/it/empty-resources/invoker.properties new file mode 100644 index 0000000..eb49748 --- /dev/null +++ b/src/it/empty-resources/invoker.properties @@ -0,0 +1,19 @@ +# 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. + +invoker.goals = resources:resources +invoker.maven.version = 3.0+ diff --git a/src/it/empty-resources/pom.xml b/src/it/empty-resources/pom.xml new file mode 100644 index 0000000..b2f6a0a --- /dev/null +++ b/src/it/empty-resources/pom.xml @@ -0,0 +1,36 @@ + + + + 4.0.0 + + org.apache.maven.plugins.maven-resources-plugin.its + empty-resources + 1.0-SNAPSHOT + + + + + org.apache.maven.plugins + maven-resources-plugin + @project.version@ + + + + diff --git a/src/it/empty-resources/verify.groovy b/src/it/empty-resources/verify.groovy new file mode 100644 index 0000000..091e7ed --- /dev/null +++ b/src/it/empty-resources/verify.groovy @@ -0,0 +1,22 @@ +/* + * 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. + */ + +content = new File(basedir, 'build.log').text + +assert !content.contains('Copying 0 resource') 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..72593d8 100644 --- a/src/main/java/org/apache/maven/plugins/resources/ResourcesMojo.java +++ b/src/main/java/org/apache/maven/plugins/resources/ResourcesMojo.java @@ -317,6 +317,10 @@ static Resource newResource(SourceRoot res) { } protected void doExecute() throws MojoException { + if (getResources().isEmpty()) { + return; + } + if ((encoding == null || encoding.isEmpty()) && isFilteringEnabled(getResources())) { getLog().warn("File encoding has not been set, using platform encoding " + System.getProperty("file.encoding") From 5c637727ac57c4ca65b76d168ad339f282b863ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Efe=20G=C3=B6kdemir?= Date: Fri, 25 Sep 2026 13:12:02 +0300 Subject: [PATCH 2/4] fix: make empty resource filtering skip observable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Efe Gökdemir --- src/it/empty-resources/invoker.properties | 1 - src/it/empty-resources/verify.groovy | 2 +- .../java/org/apache/maven/plugins/resources/ResourcesMojo.java | 1 + 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/it/empty-resources/invoker.properties b/src/it/empty-resources/invoker.properties index eb49748..aee6813 100644 --- a/src/it/empty-resources/invoker.properties +++ b/src/it/empty-resources/invoker.properties @@ -16,4 +16,3 @@ # under the License. invoker.goals = resources:resources -invoker.maven.version = 3.0+ diff --git a/src/it/empty-resources/verify.groovy b/src/it/empty-resources/verify.groovy index 091e7ed..e35a11d 100644 --- a/src/it/empty-resources/verify.groovy +++ b/src/it/empty-resources/verify.groovy @@ -19,4 +19,4 @@ content = new File(basedir, 'build.log').text -assert !content.contains('Copying 0 resource') +assert content.contains('No resources configured, skipping.') 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 72593d8..b676912 100644 --- a/src/main/java/org/apache/maven/plugins/resources/ResourcesMojo.java +++ b/src/main/java/org/apache/maven/plugins/resources/ResourcesMojo.java @@ -318,6 +318,7 @@ static Resource newResource(SourceRoot res) { protected void doExecute() throws MojoException { if (getResources().isEmpty()) { + getLog().info("No resources configured, skipping."); return; } From 2edcac159b0bd0636f62edb44747ab952779982f Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Fri, 25 Sep 2026 10:27:34 +0000 Subject: [PATCH 3/4] fix: declare empty resources in IT pom to trigger skip path The empty-resources IT was not actually testing the 'no resources configured' code path because Maven's model always provides a default src/main/resources source root. By explicitly declaring in the POM, the project model has zero resource roots, which causes the mojo to take the early-exit 'No resources configured, skipping.' path as intended. --- src/it/empty-resources/pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/src/it/empty-resources/pom.xml b/src/it/empty-resources/pom.xml index b2f6a0a..049c174 100644 --- a/src/it/empty-resources/pom.xml +++ b/src/it/empty-resources/pom.xml @@ -25,6 +25,7 @@ under the License. 1.0-SNAPSHOT + org.apache.maven.plugins From cae522ea2b53ab7fd7d336a90e0fc85bc8757c51 Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Fri, 25 Sep 2026 10:39:07 +0000 Subject: [PATCH 4/4] fix: configure empty resources as plugin parameter in IT MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The element in the POM does not clear the plugin's resources parameter in Maven 4 — getEnabledSourceRoots() still returns the default src/main/resources. Move the empty declaration into the plugin to directly set the plugin parameter to an empty list, which triggers the skip path in doExecute(). --- src/it/empty-resources/pom.xml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/it/empty-resources/pom.xml b/src/it/empty-resources/pom.xml index 049c174..c448056 100644 --- a/src/it/empty-resources/pom.xml +++ b/src/it/empty-resources/pom.xml @@ -25,12 +25,14 @@ under the License. 1.0-SNAPSHOT - org.apache.maven.plugins maven-resources-plugin @project.version@ + + +