Java – Make Maven to copy dependencies into target/lib

dependenciesjavamavenmaven-2maven-3

How do I get my project's runtime dependencies copied into the target/lib folder?

As it is right now, after mvn clean install the target folder contains only my project's jar, but none of the runtime dependencies.

Best Answer

This works for me:

<project>
  ...
  <profiles>
    <profile>
      <id>qa</id>
      <build>
        <plugins>
          <plugin>
            <artifactId>maven-dependency-plugin</artifactId>
            <executions>
              <execution>
                <phase>install</phase>
                <goals>
                  <goal>copy-dependencies</goal>
                </goals>
                <configuration>
                  <outputDirectory>${project.build.directory}/lib</outputDirectory>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
</project>