[英]Maven - How to remove module-info.class warning for shaded .jar?
So here's my problem...所以这是我的问题...
I'm packaging a Spring Boot app into an uber jar using the maven-shade plugin.我正在使用 maven-shade 插件将 Spring Boot 应用程序打包到 uber jar 中。 Simple, right?
很简单吧? Well, it is except as of recently I'm getting the following warning at the end of
mvn clean package
:好吧,除了最近我在
mvn clean package
结束时收到以下警告:
[WARNING] Discovered module-info.class. Shading will break its strong encapsulation.
It's not actually breaking anything but I'm a perfectionist and this is driving me nuts?这实际上并没有破坏任何东西,但我是一个完美主义者,这让我发疯了吗? How do I get rid of it?
我该如何摆脱它? I've tried many things but no success.
我尝试了很多东西,但没有成功。
Please help :(请帮忙 :(
As referenced in a comment, filtering out the file in the shade plugin seems to work fine for me.正如评论中所引用的,过滤掉阴影插件中的文件对我来说似乎很好。
Here's what my maven-shade-plugin
config looks like:这是我的
maven-shade-plugin
配置的样子:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.1</version>
<configuration>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>module-info.class</exclude>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
The key line is the <exclude>module-info.class</exclude>
.关键是
<exclude>module-info.class</exclude>
。 The filter excludes that file whenever it sees it, in any artifact ( *:*
= any artifact).过滤器在任何工件(
*:*
= 任何工件)中看到它时都会排除该文件。 (The other three excludes I use to get rid of bugs with signature files in dependencies) (其他三个排除我用来摆脱依赖项中签名文件的错误)
I haven't noticed any unwanted side effects from doing this, and the warning is now gone!我没有注意到这样做有任何不需要的副作用,现在警告消失了!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.