So here's my problem...
I'm packaging a Spring Boot app into an uber jar using the maven-shade plugin. Simple, right? Well, it is except as of recently I'm getting the following warning at the end of 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:
<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>
. 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!