Home > Software design >  Goal copy-dependencies in maven-dependency-plugin is not executed
Goal copy-dependencies in maven-dependency-plugin is not executed

Time:09-22

I have the following plugin configuration :

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>3.2.0</version>
                <configuration>
                    <outputDirectory>${project.build.directory}/alternateLocation</outputDirectory>
                </configuration>
                <executions>
                    <execution>
                        <id>copy-dependencies</id>
                        <phase>package</phase>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

When calling mvn dependency:copy-dependencies dependencies are indeed copied, and at the correct location (alternateLocation). But when I'm calling mvn package nothing is performed. What am I missing ?

CodePudding user response:

We only see parts of your POM, but I guess you put the plugin into <pluginManagement> and not into <plugins> where it belongs.

CodePudding user response:

As per documentation, you need to have your configuration inside the execution.

  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-dependency-plugin</artifactId>
    <version>3.2.0</version>
    <executions>
      <execution>
        <id>copy-dependencies</id>
        <phase>package</phase>
        <goals>
          <goal>copy-dependencies</goal>
        </goals>
        <configuration>
          <!-- configure the plugin here -->
        </configuration>
      </execution>
    </executions>
  </plugin>
  • Related