将类排除在阴影 Jar 中

csc*_*can 4 java jar maven maven-shade-plugin

我试图排除某些类被包含在阴影 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>
Run Code Online (Sandbox Code Playgroud)

我还尝试了以下模式:

<exclude>java.*</exclude>
<exclude>java.util.concurrent.ConcurrentHashMap</exclude>
<exclude>java/util/concurrent/ConcurrentHashMap</exclude>
Run Code Online (Sandbox Code Playgroud)

其中没有一个实际上从我的 jar 中排除了该文件。如何从我的 jar 中排除这个类?

csc*_*can 5

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

<exclude>java/**/*</exclude>
Run Code Online (Sandbox Code Playgroud)