mavenmaven-shade-plugin

Maven shade plugin does not exclude META-INF.versions files


Using Maven Shade plugin 3.6.0

I have the following filter:

                    <filters>
                        <filter>
                            <artifact>*:*</artifact>
                            <excludes>
                                <exclude>module-info.class</exclude>
                                <exclude>META-INF/LICENSE</exclude>
                                <exclude>META-INF/NOTICE</exclude>
                                <exclude>META-INF/MANIFEST.MF</exclude>
                                <exclude>META-INF.versions.9.module-info</exclude>
                            </excludes>
                        </filter>
                    </filters>

However, I continue to see the following warning:

classgraph-4.8.160.jar, jackson-core-2.17.0.jar, jackson-databind-2.15.2.jar, jackson-datatype-jdk8-2.15.2.jar, jackson-datatype-jsr310-2.15.2.jar, jackson-module-parameter-names-2.15.2.jar define 1 overlapping classes: [WARNING] - META-INF.versions.9.module-info

This is benign, but I'd still like to get rid of the warning if possible. What am I doing wrong?


Solution

  • The used filter is used wrong.

     <filters>
       <filter>
         <artifact>*:*</artifact>
         <excludes>
           <exclude>module-info.class</exclude>
           <exclude>META-INF/LICENSE</exclude>
           <exclude>META-INF/NOTICE</exclude>
           <exclude>META-INF/MANIFEST.MF</exclude>
           <exclude>META-INF/versions/9/module-info.class</exclude>
         </excludes>
       </filter>
     </filters>
    

    or to make that exclude all kind of module-info.class files for multi release jars:

     <filters>
       <filter>
         <artifact>*:*</artifact>
         <excludes>
           <exclude>module-info.class</exclude>
           <exclude>META-INF/LICENSE</exclude>
           <exclude>META-INF/NOTICE</exclude>
           <exclude>META-INF/MANIFEST.MF</exclude>
           <exclude>META-INF/versions/**/module-info.class</exclude>
         </excludes>
       </filter>
     </filters>