一、goal
maven-dependency-plugin插件最常用的goal有:copy、copy-dependencies、unpack、unpack-dependencies
copy:拷贝指定jar包到指定目录,与当前工程的依赖没有关系
copy-dependencies:拷贝依赖jar包到指定目录
unpack:解压指定jar包到指定目录,与当前工程的依赖没有关系
unpack-dependencies:解压依赖jar包到指定目录
二、copy
copy可以的配置的项比较多
<artifactItems>是必须配置的,指定jar包
<outputDirectory>默认值${project.build.directory}/dependency
1.pom文件
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId>
<artifactId>maven-haha</artifactId>
<version>1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.8</version>
<configuration>
<artifactItems>
<artifactItem>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
</artifactItem>
</artifactItems>
</configuration>
</plugin>
</plugins>
</build>
</project>
2.使用dependency:copy
mvn clean dependency:copy
结果:
三、copy-dependencies
1.pom文件
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId>
<artifactId>maven-haha</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.8</version>
</plugin>
</plugins>
</build>
</project>
2.使用dependency:copy-dependencies
mvn clean dependency:copy-dependencies
结果:
四、unpack、unpack-dependencies
unpack、unpack-dependencies是解压到指定目录,与copy、copy-dependencies操作类似