Exclude Classes from Being Included in Shaded Jar

本秂侑毒 提交于 2019-12-07 18:48:34

问题


I'm trying to exclude certain classes from being included in a shaded jar.

I have tried several different configurations but for some reason the jars are still being included in my jar. Here is the plugin setup:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-shade-plugin</artifactId>
    <version>2.4.2</version>
    <executions>
        <execution>
            <phase>package</phase>
            <goals>
                <goal>shade</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <filters>
            <filter>
                <artifact>*:*</artifact>
                <excludes>
                    <exclude>META-INF/*.SF</exclude>
                    <exclude>META-INF/*.DSA</exclude>
                    <exclude>META-INF/*.RSA</exclude>
                    <exclude>java/*</exclude>
                </excludes>
            </filter>
        </filters>
    </configuration>
</plugin>

I have also tried the following patterns:

<exclude>java.*</exclude>
<exclude>java.util.concurrent.ConcurrentHashMap</exclude>
<exclude>java/util/concurrent/ConcurrentHashMap</exclude>

None of which have actually excluded the file from my jar. How can I exclude this class from my jar?


回答1:


You are only excluding top level files in the java folder. You can exclude recursively like this:

<exclude>java/**/*</exclude>


来源:https://stackoverflow.com/questions/45683587/exclude-classes-from-being-included-in-shaded-jar

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!