如何从阴影Maven jar中排除测试依赖项? [英] How to exclude test dependencies from a shaded maven jar?

查看:114
本文介绍了如何从阴影Maven jar中排除测试依赖项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用maven-shade-plugin,我不仅想排除我的测试代码,还要排除我在阴影jar中的测试依赖项.我意识到我可以明确排除某些工件(例如junit),但这是一项很大的工作,并且很可能会出现一些错误.

I'm using the maven-shade-plugin and I'd like to exclude not only my test code, but my test dependencies in the shaded jar. I realize I can specifically exclude certain artifacts (like junit), but that's a good bit of work and prone to some error most likely.

我将minimizeJar设置为true,但是仍然看到我的Junit和Mockito依赖项.是否没有办法通过配置排除所有测试范围的依赖关系?

I'm setting minimizeJar to true, but I still see my Junit and Mockito dependencies showing up. Is there just no way to exclude all test scoped dependencies via configuration?

推荐答案

确保测试依赖项位于test范围内:

Make sure your test dependencies in the test scope:

<dependencies>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.11</version>
        <scope>test</scope>
    </dependency>
...

要检查您的依赖项设置是否使用

To check if your dependency setup use

mvn dependency:tree

这篇关于如何从阴影Maven jar中排除测试依赖项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆