You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by sl...@apache.org on 2026/10/19 13:36:34 UTC

(maven-dependency-plugin) branch master updated (247ac3b4 -> 14c46007)

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

slachiewicz pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/maven-dependency-plugin.git


    from 247ac3b4 [MDEP-569] Add remoteRepositories to copy and unpack
     new 5da14c16 [MDEP-458] Skip classifier-translated artifacts that are already up to date
     new 14c46007 [MDEP-458] Assert on the Overwriting warning in the IT

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../invoker.properties                             |  0
 .../pom.xml                                        | 38 ++++++++++------------
 .../verify.groovy                                  | 14 ++++++--
 .../AbstractDependencyFilterMojo.java              | 12 +++----
 .../fromDependencies/TestCopyDependenciesMojo.java | 35 ++++++++++++++++++++
 5 files changed, 69 insertions(+), 30 deletions(-)
 copy src/it/projects/{copy-broken-parent => mdep-458-classifier-overwrite}/invoker.properties (100%)
 copy src/it/projects/{copy-relocation-without-version => mdep-458-classifier-overwrite}/pom.xml (71%)
 copy src/it/projects/{copy-relocation => mdep-458-classifier-overwrite}/verify.groovy (72%)


(maven-dependency-plugin) 02/02: [MDEP-458] Assert on the Overwriting warning in the IT

Posted by sl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

slachiewicz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-dependency-plugin.git

commit 14c46007e28ea5b1ed252e127057e534732df6ef
Author: Sylwester Lachiewicz <sl...@apache.org>
AuthorDate: Wed Oct 14 00:02:24 2026 +0200

    [MDEP-458] Assert on the Overwriting warning in the IT
---
 src/it/projects/mdep-458-classifier-overwrite/verify.groovy | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/it/projects/mdep-458-classifier-overwrite/verify.groovy b/src/it/projects/mdep-458-classifier-overwrite/verify.groovy
index 0d4f4625..230426fe 100644
--- a/src/it/projects/mdep-458-classifier-overwrite/verify.groovy
+++ b/src/it/projects/mdep-458-classifier-overwrite/verify.groovy
@@ -23,6 +23,6 @@ String log = new File( basedir, 'build.log' ).text
 assert log.contains( '(first)' ) && log.contains( '(second)' )
 String afterSecond = log.substring( log.indexOf( '(second)' ) )
 assert afterSecond.contains( 'already exists in destination' )
-assert !afterSecond.contains( 'Copying ResourceArtifact-1.0-client.jar' )
+assert !afterSecond.contains( 'Overwriting ' )
 
 return true


(maven-dependency-plugin) 01/02: [MDEP-458] Skip classifier-translated artifacts that are already up to date

Posted by sl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

slachiewicz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-dependency-plugin.git

commit 5da14c16a6ed04ddf07f9c7b38ec9fec42413214
Author: Sylwester Lachiewicz <sl...@apache.org>
AuthorDate: Tue Oct 13 23:26:39 2026 +0200

    [MDEP-458] Skip classifier-translated artifacts that are already up to date
---
 .../invoker.properties                             | 18 ++++++
 .../projects/mdep-458-classifier-overwrite/pom.xml | 67 ++++++++++++++++++++++
 .../mdep-458-classifier-overwrite/verify.groovy    | 28 +++++++++
 .../AbstractDependencyFilterMojo.java              | 12 ++--
 .../fromDependencies/TestCopyDependenciesMojo.java | 35 +++++++++++
 5 files changed, 154 insertions(+), 6 deletions(-)

diff --git a/src/it/projects/mdep-458-classifier-overwrite/invoker.properties b/src/it/projects/mdep-458-classifier-overwrite/invoker.properties
new file mode 100644
index 00000000..101be4e9
--- /dev/null
+++ b/src/it/projects/mdep-458-classifier-overwrite/invoker.properties
@@ -0,0 +1,18 @@
+# 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 = clean process-sources
diff --git a/src/it/projects/mdep-458-classifier-overwrite/pom.xml b/src/it/projects/mdep-458-classifier-overwrite/pom.xml
new file mode 100644
index 00000000..c481b8b7
--- /dev/null
+++ b/src/it/projects/mdep-458-classifier-overwrite/pom.xml
@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ 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.
+  -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.apache.maven.its.dependency</groupId>
+  <artifactId>mdep-458-classifier-overwrite</artifactId>
+  <version>1.0-SNAPSHOT</version>
+  <description>copy-dependencies with a classifier must not overwrite a file that is already up to date (MDEP-458).</description>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.maven.its.dependency</groupId>
+      <artifactId>ResourceArtifact</artifactId>
+      <version>1.0</version>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <artifactId>maven-dependency-plugin</artifactId>
+        <version>@project.version@</version>
+        <executions>
+          <execution>
+            <id>first</id>
+            <phase>process-sources</phase>
+            <goals>
+              <goal>copy-dependencies</goal>
+            </goals>
+            <configuration>
+              <classifier>client</classifier>
+            </configuration>
+          </execution>
+          <execution>
+            <id>second</id>
+            <phase>process-sources</phase>
+            <goals>
+              <goal>copy-dependencies</goal>
+            </goals>
+            <configuration>
+              <classifier>client</classifier>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>
diff --git a/src/it/projects/mdep-458-classifier-overwrite/verify.groovy b/src/it/projects/mdep-458-classifier-overwrite/verify.groovy
new file mode 100644
index 00000000..0d4f4625
--- /dev/null
+++ b/src/it/projects/mdep-458-classifier-overwrite/verify.groovy
@@ -0,0 +1,28 @@
+/*
+ * 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.
+ */
+
+assert new File( basedir, 'target/dependency/ResourceArtifact-1.0-client.jar' ).isFile()
+
+String log = new File( basedir, 'build.log' ).text
+assert log.contains( '(first)' ) && log.contains( '(second)' )
+String afterSecond = log.substring( log.indexOf( '(second)' ) )
+assert afterSecond.contains( 'already exists in destination' )
+assert !afterSecond.contains( 'Copying ResourceArtifact-1.0-client.jar' )
+
+return true
diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/AbstractDependencyFilterMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/AbstractDependencyFilterMojo.java
index 63d08540..92ad48d8 100644
--- a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/AbstractDependencyFilterMojo.java
+++ b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/AbstractDependencyFilterMojo.java
@@ -444,17 +444,17 @@ public abstract class AbstractDependencyFilterMojo extends AbstractDependencyMoj
             ArtifactTranslator translator = createArtifactTranslator();
             Collection<org.eclipse.aether.artifact.Artifact> coordinates = translator.translate(artifacts, getLog());
 
-            status = filterMarkedDependencies(artifacts);
-
-            // the unskipped artifacts are in the resolved set.
-            artifacts = status.getResolvedDependencies();
-
-            // resolve the rest of the artifacts
+            // resolve the translated artifacts
             resolvedArtifacts = resolve(new LinkedHashSet<>(coordinates), stopOnFailure);
 
             // calculate the artifacts not resolved.
             unResolvedArtifacts.addAll(artifacts);
             unResolvedArtifacts.removeAll(resolvedArtifacts);
+
+            // skip the translated artifacts that are already up to date in the destination: the destination file
+            // name depends on the classifier, so the decision cannot be taken on the original artifacts
+            status = filterMarkedDependencies(resolvedArtifacts);
+            resolvedArtifacts = status.getResolvedDependencies();
         }
 
         // return a bean of all 3 sets.
diff --git a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo.java b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo.java
index 83715c63..31d0ef5f 100644
--- a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo.java
+++ b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo.java
@@ -437,6 +437,41 @@ class TestCopyDependenciesMojo {
         }
     }
 
+    @Test
+    @InjectMojo(goal = "copy-dependencies")
+    void testClassifierDoesNotOverwriteUpToDateFile(CopyDependenciesMojo mojo) throws Exception {
+        mojo.classifier = "jdk14";
+        for (Artifact artifact : mojo.getProject().getArtifacts()) {
+            stubFactory.createArtifact(
+                    artifact.getGroupId(),
+                    artifact.getArtifactId(),
+                    artifact.getVersion(),
+                    artifact.getScope(),
+                    artifact.getType(),
+                    "jdk14");
+        }
+
+        mojo.execute();
+
+        long newer = System.currentTimeMillis() + 3_600_000L;
+        for (Artifact artifact : mojo.getProject().getArtifacts()) {
+            File copied = new File(
+                    mojo.outputDirectory,
+                    artifact.getArtifactId() + "-" + artifact.getVersion() + "-jdk14." + artifact.getType());
+            assertTrue(copied.exists(), copied.getAbsolutePath());
+            assertTrue(copied.setLastModified(newer));
+        }
+
+        mojo.execute();
+
+        for (Artifact artifact : mojo.getProject().getArtifacts()) {
+            File copied = new File(
+                    mojo.outputDirectory,
+                    artifact.getArtifactId() + "-" + artifact.getVersion() + "-jdk14." + artifact.getType());
+            assertEquals(newer / 1000, copied.lastModified() / 1000, copied.getName() + " was overwritten");
+        }
+    }
+
     @Test
     @InjectMojo(goal = "copy-dependencies")
     void testSubPerType(CopyDependenciesMojo mojo) throws Exception {