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

cstamas pushed a commit to branch maven-resources-plugin-3.x-issue-453
in repository https://gitbox.apache.org/repos/asf/maven-resources-plugin.git

commit 04301c203d99bfee77f78aaae409fc16572ba3c7
Author: Tamas Cservenak <[email protected]>
AuthorDate: Thu Feb 19 21:26:12 2026 +0100

    Bug: use change detecton strategies
    
    Use the change detection strategy from maven-filtering
    
    Fixes #453
---
 pom.xml                                            |  3 +-
 .../maven/plugins/resources/ResourcesMojo.java     | 45 +++++++++++++++++++++-
 2 files changed, 46 insertions(+), 2 deletions(-)

diff --git a/pom.xml b/pom.xml
index aaff0bf..56cfcf5 100644
--- a/pom.xml
+++ b/pom.xml
@@ -71,10 +71,11 @@ under the License.
   </distributionManagement>
 
   <properties>
-    <mavenFilteringVersion>3.4.0</mavenFilteringVersion>
+    <mavenFilteringVersion>3.4.1-SNAPSHOT</mavenFilteringVersion>
     <mavenVersion>3.9.12</mavenVersion>
     <javaVersion>8</javaVersion>
     
<project.build.outputTimestamp>2025-11-22T21:31:20Z</project.build.outputTimestamp>
+    <version.plexus-utils>3.6.0</version.plexus-utils>
 
     <version.maven-invoker-plugin>3.9.1</version.maven-invoker-plugin>
   </properties>
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 27dd610..f632440 100644
--- a/src/main/java/org/apache/maven/plugins/resources/ResourcesMojo.java
+++ b/src/main/java/org/apache/maven/plugins/resources/ResourcesMojo.java
@@ -39,6 +39,7 @@ import org.apache.maven.plugins.annotations.LifecyclePhase;
 import org.apache.maven.plugins.annotations.Mojo;
 import org.apache.maven.plugins.annotations.Parameter;
 import org.apache.maven.project.MavenProject;
+import org.apache.maven.shared.filtering.ChangeDetection;
 import org.apache.maven.shared.filtering.MavenFilteringException;
 import org.apache.maven.shared.filtering.MavenResourcesExecution;
 import org.apache.maven.shared.filtering.MavenResourcesFiltering;
@@ -156,10 +157,31 @@ public class ResourcesMojo extends AbstractMojo {
      * Overwrite existing files even if the destination files are newer.
      *
      * @since 2.3
+     * @deprecated Use {@link #changeDetection} instead.
      */
+    @Deprecated
     @Parameter(defaultValue = "false")
     private boolean overwrite;
 
+    /**
+     * The strategy to use for change detection. Supported values are 
"content" (default), "timestamp", "combined"
+     * and "always" (equivalent of {@link #overwrite set to {@code true}}).
+     *
+     * Strategies and their behavior are as follows:
+     * <ul>
+     *     <li><strong>content</strong>: This is the default strategy since 
version 3.4.0. Overwrites existing target file only if content differs.</li>
+     *     <li><strong>timestamp</strong>: This was the default strategy 
before version 3.4.0. Overwrites existing target file only if timestamp is 
older that source file timestamp.</li>
+     *     <li><strong>combined</strong>: Combines the two strategies above; 
if timestamp is older and if content differs, file will be overwritten.</li>
+     *     <li><strong>always</strong>: Always overwrites the target file. 
Equivalent of {@code overwrite=true}.</li>
+     * </ul>
+     *
+     * Note: default value of this parameter is handled programmatically (as 
"content") for programmatic detection reasons.
+     *
+     * @since 3.5.0
+     */
+    @Parameter
+    private String changeDetection;
+
     /**
      * Copy any empty directories included in the Resources.
      *
@@ -323,7 +345,7 @@ public class ResourcesMojo extends AbstractMojo {
             mavenResourcesExecution.setInjectProjectBuildFilters(false);
 
             mavenResourcesExecution.setEscapeString(escapeString);
-            mavenResourcesExecution.setOverwrite(overwrite);
+            mavenResourcesExecution.setChangeDetection(getChangeDetection());
             mavenResourcesExecution.setIncludeEmptyDirs(includeEmptyDirs);
             
mavenResourcesExecution.setSupportMultiLineFiltering(supportMultiLineFiltering);
             mavenResourcesExecution.setFilterFilenames(fileNameFiltering);
@@ -350,6 +372,27 @@ public class ResourcesMojo extends AbstractMojo {
         }
     }
 
+    private ChangeDetection getChangeDetection() {
+        if (changeDetection != null) {
+            switch (changeDetection) {
+                case "content":
+                    return ChangeDetection.CONTENT;
+                case "timestamp":
+                    return ChangeDetection.TIMESTAMP;
+                case "combined":
+                    return ChangeDetection.COMBINED;
+                case "always":
+                    return ChangeDetection.ALWAYS;
+                default:
+                    throw new IllegalArgumentException("Invalid value for 
changeDetection: " + changeDetection);
+            }
+        } else if (overwrite) {
+            return ChangeDetection.ALWAYS;
+        } else {
+            return ChangeDetection.CONTENT;
+        }
+    }
+
     /**
      * This solves https://issues.apache.org/jira/browse/MRESOURCES-99.<br/>
      * BUT:<br/>

Reply via email to