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/13 17:40:13 UTC

(maven-dependency-plugin) branch master updated (c3000d9a -> 4a6179f6)

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 c3000d9a Keep Dependabot on Maven 3.9.x
     new f61cf6f7 [MDEP-587] Reproduce missing artifact type classifiers
     new 4a6179f6 [MDEP-587] Honor artifact type default classifiers

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:
 .../client.txt}                                    |  2 +-
 .../tests.txt}                                     |  2 +-
 .../invoker.properties                             |  0
 .../pom.xml                                        | 66 +++++++++++++---------
 .../verify.groovy                                  | 25 ++++----
 .../AbstractFromConfigurationMojo.java             |  7 ++-
 .../dependency/fromConfiguration/TestCopyMojo.java | 48 ++++++++++++++++
 7 files changed, 106 insertions(+), 44 deletions(-)
 copy src/it/mrm/repository/{ResourceArtifact-1.0.jar/resource2.txt => ResourceArtifact-1.0-client.jar/client.txt} (98%)
 copy src/it/mrm/repository/{ResourceArtifact-1.0.jar/resource2.txt => ResourceArtifact-1.0-tests.jar/tests.txt} (98%)
 copy src/it/projects/{copy-broken-parent => mdep-587-artifact-type-classifier}/invoker.properties (100%)
 copy src/it/projects/{copy-and-unpack-with-alternate-local-repo => mdep-587-artifact-type-classifier}/pom.xml (51%)
 copy src/it/projects/{mdep-1650-scriptable-output-null-classifier => mdep-587-artifact-type-classifier}/verify.groovy (60%)


(maven-dependency-plugin) 01/02: [MDEP-587] Reproduce missing artifact type classifiers

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 f61cf6f7a74519f38ebf48b5b562e1c1df4f047a
Author: Vaclav Haisman <vh...@gmail.com>
AuthorDate: Sat Sep 19 22:58:02 2026 +0200

    [MDEP-587] Reproduce missing artifact type classifiers
    
    Add copy regression tests for test-jar, ejb-client, java-source and javadoc, plus explicit classifier overrides. Exercise both copy and unpack in an integration test with distinct main and classified archives.
    
    The implicit-classifier cases fail on the current implementation because it selects the main JAR.
---
 .../ResourceArtifact-1.0-client.jar/client.txt     | 20 +++++
 .../ResourceArtifact-1.0-tests.jar/tests.txt       | 20 +++++
 .../invoker.properties                             | 18 ++++
 .../mdep-587-artifact-type-classifier/pom.xml      | 97 ++++++++++++++++++++++
 .../verify.groovy                                  | 31 +++++++
 .../dependency/fromConfiguration/TestCopyMojo.java | 48 +++++++++++
 6 files changed, 234 insertions(+)

diff --git a/src/it/mrm/repository/ResourceArtifact-1.0-client.jar/client.txt b/src/it/mrm/repository/ResourceArtifact-1.0-client.jar/client.txt
new file mode 100644
index 00000000..33e63047
--- /dev/null
+++ b/src/it/mrm/repository/ResourceArtifact-1.0-client.jar/client.txt
@@ -0,0 +1,20 @@
+/*
+ * 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.
+ */
+
+Resource client
diff --git a/src/it/mrm/repository/ResourceArtifact-1.0-tests.jar/tests.txt b/src/it/mrm/repository/ResourceArtifact-1.0-tests.jar/tests.txt
new file mode 100644
index 00000000..f32137fe
--- /dev/null
+++ b/src/it/mrm/repository/ResourceArtifact-1.0-tests.jar/tests.txt
@@ -0,0 +1,20 @@
+/*
+ * 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.
+ */
+
+Resource tests
diff --git a/src/it/projects/mdep-587-artifact-type-classifier/invoker.properties b/src/it/projects/mdep-587-artifact-type-classifier/invoker.properties
new file mode 100644
index 00000000..101be4e9
--- /dev/null
+++ b/src/it/projects/mdep-587-artifact-type-classifier/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-587-artifact-type-classifier/pom.xml b/src/it/projects/mdep-587-artifact-type-classifier/pom.xml
new file mode 100644
index 00000000..bff12b14
--- /dev/null
+++ b/src/it/projects/mdep-587-artifact-type-classifier/pom.xml
@@ -0,0 +1,97 @@
+<?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-587-artifact-type-classifier</artifactId>
+  <version>1.0-SNAPSHOT</version>
+  <description>Copy and unpack must use the artifact type's default classifier unless explicitly overridden.</description>
+  <build>
+    <plugins>
+      <plugin>
+        <artifactId>maven-dependency-plugin</artifactId>
+        <version>@project.version@</version>
+        <executions>
+          <execution>
+            <id>test-jar</id>
+            <goals>
+              <goal>copy</goal>
+              <goal>unpack</goal>
+            </goals>
+            <configuration>
+              <artifactItems>
+                <artifactItem>
+                  <groupId>org.apache.maven.its.dependency</groupId>
+                  <artifactId>ResourceArtifact</artifactId>
+                  <version>1.0</version>
+                  <type>test-jar</type>
+                  <outputDirectory>${project.build.directory}/test-jar</outputDirectory>
+                </artifactItem>
+              </artifactItems>
+              <markersDirectory>${project.build.directory}/markers/test-jar</markersDirectory>
+            </configuration>
+          </execution>
+          <execution>
+            <id>ejb-client</id>
+            <goals>
+              <goal>copy</goal>
+              <goal>unpack</goal>
+            </goals>
+            <configuration>
+              <artifactItems>
+                <artifactItem>
+                  <groupId>org.apache.maven.its.dependency</groupId>
+                  <artifactId>ResourceArtifact</artifactId>
+                  <version>1.0</version>
+                  <type>ejb-client</type>
+                  <outputDirectory>${project.build.directory}/ejb-client</outputDirectory>
+                </artifactItem>
+              </artifactItems>
+              <markersDirectory>${project.build.directory}/markers/ejb-client</markersDirectory>
+            </configuration>
+          </execution>
+          <execution>
+            <id>explicit-classifier</id>
+            <goals>
+              <goal>copy</goal>
+              <goal>unpack</goal>
+            </goals>
+            <configuration>
+              <artifactItems>
+                <artifactItem>
+                  <groupId>org.apache.maven.its.dependency</groupId>
+                  <artifactId>ResourceArtifact</artifactId>
+                  <version>1.0</version>
+                  <type>test-jar</type>
+                  <classifier>client</classifier>
+                  <outputDirectory>${project.build.directory}/explicit-classifier</outputDirectory>
+                </artifactItem>
+              </artifactItems>
+              <markersDirectory>${project.build.directory}/markers/explicit-classifier</markersDirectory>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>
diff --git a/src/it/projects/mdep-587-artifact-type-classifier/verify.groovy b/src/it/projects/mdep-587-artifact-type-classifier/verify.groovy
new file mode 100644
index 00000000..6c3b5814
--- /dev/null
+++ b/src/it/projects/mdep-587-artifact-type-classifier/verify.groovy
@@ -0,0 +1,31 @@
+/*
+ * 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.
+ */
+
+[ 'test-jar': 'tests', 'ejb-client': 'client', 'explicit-classifier': 'client' ].each { directory, classifier ->
+    File output = new File( basedir, 'target/' + directory )
+    assert new File( output, 'ResourceArtifact-1.0-' + classifier + '.jar' ).isFile()
+    assert new File( output, classifier + '.txt' ).isFile()
+    assert !new File( output, 'ResourceArtifact-1.0.jar' ).exists()
+    assert !new File( output, 'resource1.txt' ).exists()
+    if ( classifier == 'client' ) {
+        assert !new File( output, 'tests.txt' ).exists()
+    }
+}
+
+return true
diff --git a/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestCopyMojo.java b/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestCopyMojo.java
index cd664a0c..019116e8 100644
--- a/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestCopyMojo.java
+++ b/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestCopyMojo.java
@@ -168,6 +168,54 @@ class TestCopyMojo {
         assertFilesExist(list);
     }
 
+    @Test
+    @InjectMojo(goal = "copy")
+    void testCopyTestJarWithImplicitClassifier(CopyMojo mojo) throws Exception {
+        assertCopyArtifactType(mojo, "test-jar", null, "tests");
+    }
+
+    @Test
+    @InjectMojo(goal = "copy")
+    void testCopyEjbClientWithImplicitClassifier(CopyMojo mojo) throws Exception {
+        assertCopyArtifactType(mojo, "ejb-client", null, "client");
+    }
+
+    @Test
+    @InjectMojo(goal = "copy")
+    void testCopyJavaSourceWithImplicitClassifier(CopyMojo mojo) throws Exception {
+        assertCopyArtifactType(mojo, "java-source", null, "sources");
+    }
+
+    @Test
+    @InjectMojo(goal = "copy")
+    void testCopyJavadocWithImplicitClassifier(CopyMojo mojo) throws Exception {
+        assertCopyArtifactType(mojo, "javadoc", null, "javadoc");
+    }
+
+    @Test
+    @InjectMojo(goal = "copy")
+    void testCopyArtifactTypeWithExplicitClassifier(CopyMojo mojo) throws Exception {
+        assertCopyArtifactType(mojo, "test-jar", "client", "client");
+    }
+
+    private void assertCopyArtifactType(CopyMojo mojo, String type, String classifier, String expectedClassifier)
+            throws Exception {
+        // Keep the main jar available so the regression copies the wrong artifact instead of failing resolution.
+        stubFactory.createArtifact("groupId", "artifact", "1.0", null, "jar", null);
+        stubFactory.createArtifact("groupId", "artifact", "1.0", null, "jar", "tests");
+        stubFactory.createArtifact("groupId", "artifact", "1.0", null, "jar", expectedClassifier);
+        mojo.setLocalRepositoryDirectory(stubFactory.getWorkingDir());
+        mojo.setArtifact("groupId:artifact:1.0:" + type + (classifier == null ? "" : ":" + classifier));
+
+        mojo.execute();
+
+        ArtifactItem item = mojo.getArtifactItems().get(0);
+        assertEquals(expectedClassifier, item.getArtifact().getClassifier());
+        assertEquals("artifact-1.0-" + expectedClassifier + ".jar", item.getDestFileName());
+        assertFileExists(item);
+        assertFalse(new File(mojo.getOutputDirectory(), "artifact-1.0.jar").exists());
+    }
+
     /**
      * TODO move to an integration test ...
      */


(maven-dependency-plugin) 02/02: [MDEP-587] Honor artifact type default classifiers

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 4a6179f6f1e35ee3716eaea022522f3736b60452
Author: Vaclav Haisman <vh...@gmail.com>
AuthorDate: Sat Sep 19 22:58:55 2026 +0200

    [MDEP-587] Honor artifact type default classifiers
    
    Use the artifact handler classifier when no classifier is explicitly configured for copy or unpack. Preserve explicit overrides and the existing extension fallback for unknown types.
    
    Fixes #1026.
---
 .../fromConfiguration/AbstractFromConfigurationMojo.java           | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/AbstractFromConfigurationMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/AbstractFromConfigurationMojo.java
index f5a42f81..2a6b83f7 100644
--- a/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/AbstractFromConfigurationMojo.java
+++ b/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/AbstractFromConfigurationMojo.java
@@ -238,10 +238,15 @@ public abstract class AbstractFromConfigurationMojo extends AbstractDependencyMo
 
         try {
             final String extension;
+            String classifier = artifactItem.getClassifier();
 
             ArtifactHandler artifactHandler = artifactHandlerManager.getArtifactHandler(artifactItem.getType());
             if (artifactHandler != null) {
                 extension = artifactHandler.getExtension();
+                // Types such as test-jar supply a default classifier; an explicit classifier takes precedence.
+                if (classifier == null) {
+                    classifier = artifactHandler.getClassifier();
+                }
             } else {
                 extension = artifactItem.getType();
             }
@@ -249,7 +254,7 @@ public abstract class AbstractFromConfigurationMojo extends AbstractDependencyMo
             DefaultArtifact artifact = new DefaultArtifact(
                     artifactItem.getGroupId(),
                     artifactItem.getArtifactId(),
-                    artifactItem.getClassifier(),
+                    classifier,
                     extension,
                     artifactItem.getVersion());