How can I remove module-info.class warning for a shaded .jar?

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!

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)