maven打jar包含依赖包_maven-dependency-plugin提取项目依赖的JAR

4ff5500a3bdecc2226175079adcafea2.png

本地打包项目时,在pom.xml上添加maven-dependency-plugin插件可以分析项目依赖的jar包,并生成jar报告。

<plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy-dependencies</id>
                        <phase>package</phase>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>
                                ${project.build.directory}/lib/
                            </outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

添加插件后,选择dependency:analyze-report

153c6296e05721b093ab07b4a7d300f5.png

生成的报告

87b35c9d3365aa8df01f46f7ca899b66.png

这个插件配置不仅分析jar包依赖,同时把app.jar里的jar包复制出来了,在target目录下生成了一个lib目录,把所有的app.jar里面的jar包都复制到这里面。这样后面使用owasp dependency-check插件时,扫描jar包时就会扫描lib目录下的jar。否则会扫描app.jar里面的jar包。

jeinkins上构建项目时如果想使用maven-dependency-plugin插件分析项目jar包依赖,只需在maven的打包命令后添加dependency:analyze-report即可,不需要在pom.xml中配置插件

mvn clean package -Dmaven.test.skip=true -pl xx.xx.xx:模块名 -am dependency:analyze-report

项目构建后,可在相应的模块的工作空间下看到生成的jar包依赖报告

0387c1f75fe97c5c62056f90408f3f21.png
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值