Including Runtime Dependencies in Target/Lib Folder with Maven
When building a project with Maven, it's often desirable to include the runtime dependencies in the target/lib folder. By default, the target folder only contains the project's JAR.
To resolve this issue, we can utilize the Maven Dependency Plugin. Here's a solution:
Maven Configuration:
To copy the runtime dependencies into the target/lib folder, modify your Maven configuration to include the following:
<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>
Explanation:
Usage:
To activate the 'qa' profile and copy the dependencies, execute the following command:
mvn clean install -Pqa
This process will ensure that the target/lib folder contains the project's runtime dependencies after the build.
The above is the detailed content of How to include runtime dependencies in the target/lib folder with Maven?. For more information, please follow other related articles on the PHP Chinese website!