【Maven】maven-dependency-plugin

http://maven.apache.org/components/plugins/maven-dependency-plugin/plugin-info.htmlhtml

典型场景:apache

  1.须要某个特殊的 jar包,可是有不能直接经过maven依赖获取,或者说在其余环境的maven仓库内不存在,那么如何将咱们所须要的jar包打入咱们的生产jar包中。maven

  2.某个jar包内部包含的文件是咱们所须要的,或者是咱们但愿将它提取出来放入指定的位置 ,那么除了复制粘贴,如何经过maven插件实现呢?测试

dependency插件咱们最经常使用到的是ui

  dependency:copy url

  dependency:copy-dependencies:Goal that copies the project dependencies from the repository to a defined location.   spa

  dependency:unpack    .net

  dependency:unpack-dependencies 这四个插件

若是要实现上述的两种场景,咱们须要的 是 第一个和第三个。code

 copy

  样例:将两个指定的jar包junit slf4j-log4j12 分别输出到${project.build.directory}/lib/lib1 目录下  即${project.basedir}/target/lib 目录下。  

  

 

 

 dependency:unpack 

    

 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打包命令:

相关文章
相关标签/搜索