Copying Dependencies to target/lib with Maven
Maven is a widely used build tool in Java projects. It manages dependencies and automates various build tasks. One common requirement in Java projects is to copy the runtime dependencies into a specific location within the build artifacts, typically target/lib for packaging purposes.
Solution
To achieve this in Maven, you can leverage the maven-dependency-plugin. Here's a configuration example:
<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>
By adding this configuration to your Maven project, you can specify the target directory (target/lib in this case) where the runtime dependencies should be copied during the install phase. This will ensure that the JAR files of the dependencies are included along with your project's JAR when you execute mvn clean install.
The above is the detailed content of How to Copy Dependencies to target/lib with Maven?. For more information, please follow other related articles on the PHP Chinese website!