gnodet-bot commented on code in PR #520:
URL: 
https://github.com/apache/maven-resources-plugin/pull/520#discussion_r4103398031


##########
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')

Review Comment:
   **The assertion is a no-op** — it passes even *without* the fix.
   
   The message `"Copying X resource"` is logged inside 
`DefaultMavenResourcesFiltering.filterResources()` once per resource directory, 
inside the `for (Resource resource : ...)` loop. When the resources list is 
empty, the loop body never executes, so `"Copying 0 resource"` is never logged 
— with or without the early-return guard.
   
   You need an assertion that actually distinguishes the fixed behaviour from 
the unfixed behaviour. For example, you could assert that the plugin was 
silently skipped (e.g. verify the output directory was **not** created, or add 
a log message like `"No resources configured, skipping."` in the guard and 
assert its presence).



##########
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+

Review Comment:
   `invoker.maven.version = 3.0+` is wrong here. This plugin version 
(`4.0.0-beta-2-SNAPSHOT`) requires Maven 4 (`mavenVersion` property is 
`4.0.0-rc-7` in the POM). With `3.0+` the IT would be selected to run against a 
Maven 3 installation where the plugin cannot work.
   
   Check what the other ITs in this module use — you likely don't need this 
line at all (the invoker plugin inherits a default from the parent), or it 
should specify the Maven 4 requirement.



##########
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;

Review Comment:
   Nit: consider adding a debug or info log so the early exit is observable:
   ```suggestion
           if (getResources().isEmpty()) {
               getLog().info("No resources configured, skipping.");
               return;
           }
   ```
   This is consistent with `DefaultMavenResourcesFiltering.filterResources()` 
which logs `"No resources configured skip copying/filtering"` for the `null` 
case.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to