从包含在阴影罐中排除 类

Exclude Classes from Being Included in Shaded Jar

我正在尝试将某些 classes 排除在阴影 jar 之外。

我尝试了几种不同的配置,但出于某种原因,这些罐子仍然包含在我的罐子里。这是插件设置:

<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>

我也试过以下模式:

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

None 其中实际上已经从我的 jar 中排除了该文件。我怎样才能从我的 jar 中排除这个 class?

您只排除了 java 文件夹中的顶级文件。您可以像这样递归排除:

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