【问题标题】:Exclude Classes from Being Included in Shaded Jar将类排除在 Shaded Jar 中
【发布时间】:2018-01-22 19:51:42
【问题描述】:

我正在尝试将某些类排除在阴影 jar 中。

我尝试了几种不同的配置,但由于某种原因,我的 jar 中仍然包含 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>

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

【问题讨论】:

    标签: java maven jar maven-shade-plugin


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 2011-12-10
      • 2016-06-04
      • 1970-01-01
      • 2014-06-13
      • 2016-05-22
      • 2020-07-06
      • 1970-01-01
      • 1970-01-01
      • 2011-05-04
      相关资源
      最近更新 更多