Skip to content

[MDEP-590] dependency:copy confused when asked to copy artifact with classifier and extension .POM #1024

Closed
apache/maven
#12658

Description

@jira-importer

Bertrand Renuart opened MDEP-590 and commented

Suppose you ask the maven-dependency-plugin to copy an artifact with the following coordinates:

  • groupId: group
  • artifactId: artifact
  • version: 1.0-SNAPSHOT
  • classifier: custom
  • type: pom

This is done with the following configuration:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-dependency-plugin</artifactId>
  <version>3.0.2</version>
  <executions>
    <execution>
      <phase>generate-resources</phase>
      <goals>
        <goal>copy</goal>
      </goals>
      <configuration>
        <artifactItems>
          <artifactItem>
            <groupId>group</groupId>
            <artifactId>artifact</artifactId>
            <version>1.0-SNAPSHOT</version>
            <classifier>custom</classifier>
            <type>pom</type>
          </artifactItem>
        </artifactItems>
      </configuration>
    </execution>
  </executions>
</plugin>

The MOJO will fail to copy the artifact with classifier=custom, type=pom but will instead copy the primary .POM artifact. However, things are ok when type is set to xml instead of pom.
It seems the mojo totally ignores the classifier whenever the type is pom...

I have attached a sample project made of two modules to reproduce the issue.
The first module has an additional artifact of type pom and classifier custom attached to it via the build-helper-maven-plugin
The second module attempts to copy that additional artifact with the maven-dependency-plugin.
Run it with mvn package. The result of the copy is in module-b/target/copied-custom.pom.
It is ecpected this file is a copy of module-a/custom.xml but is actually a copy of the primary pom, ie module-a/pom.xml.


Affects: 3.0.0, 3.0.1, 3.0.2

Attachments:

Activity

  1. added
    bug
    priority:major
    on Jun 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugpriority:major

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions