http://maven.apache.org/components/plugins/maven-dependency-plugin/plugin-info.html
典型场景:
1.需要某个特殊的 jar包,但是有不能直接通过maven依赖获取,或者说在其他环境的maven仓库内不存在,那么如何将我们所需要的jar包打入我们的生产jar包中。
2.某个jar包内部包含的文件是我们所需要的,或者是我们希望将它提取出来放入指定的位置 ,那么除了复制粘贴,如何通过maven插件实现呢?
dependency插件我们最常用到的是
dependency:copy
dependency:copy-dependencies:Goal that copies the project dependencies from the repository to a defined location.
dependency:unpack
dependency:unpack-dependencies 这四个
如果要实现上述的两种场景,我们需要的 是 第一个和第三个。
copy
样例:将两个指定的jar包junit slf4j-log4j12 分别输出到${project.build.directory}/lib/lib1 目录下 即${project.basedir}/target/lib 目录下。


copy-dependencies
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.10</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/deploydependencis</outputDirectory>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>false</overWriteSnapshots>
<overWriteIfNewer>true</overWriteIfNewer>
<includeScope>compile</includeScope>
<includeScope>runtime</includeScope>
</configuration>
</execution>
</executions>
</plugin>
测试样例:
执行MVN打包命令:

