13

我在 pom.xml 中有一个部分

 <filters>
   <filter>
      <artifact>*:*</artifact>
         <excludes>
            <exclude>META-INF/*.SF</exclude>
            <exclude>META-INF/*.DSA</exclude>
         </excludes>
   </filter>
</filters>

我想从最终的 jar 中排除 *.SF 和 *.DSA 文件。但我收到以下消息:

[INFO] No artifact matching filter *:*

并且不排除文件。有谁知道如何克服它?

4

3 回答 3

13

实际上你可以进行全局过滤而不需要指定组 id,你只需要使用正确的通配符语法。例如,如果要从 jar 中排除所有 *.RSA 文件,请将 artifactId 指定为*:*:*:*

<filters>
    <filter>
        <artifact>*:*:*:*</artifact>
        <excludes>
            <exclude>*.RSA</exclude>
        </excludes>
    </filter>
</filters>
于 2014-09-16T18:17:29.377 回答
8

我有同样的问题。通过使我的工件选择器更具体来修复它,例如

<artifact>bouncycastle:*</artifact>

整个区块看起来像这样:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-shade-plugin</artifactId>
    <executions>
        <execution>
            <phase>package</phase>
            <goals>
                <goal>shade</goal>
            </goals>
            <configuration>
                <transformers>
                    <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                        <mainClass>com.mycompany.MainClass</mainClass>
                    </transformer>
                </transformers>
                <filters>
                    <filter>
                        <artifact>bouncycastle:*</artifact>
                        <excludes>
                            <exclude>META-INF/*.SF</exclude>
                            <exclude>META-INF/*.DSA</exclude>
                            <exclude>META-INF/*.RSA</exclude>
                        </excludes>
                    </filter>
                </filters>
                <shadedArtifactAttached>true</shadedArtifactAttached>
                <shadedClassifierName>standalone</shadedClassifierName>
            </configuration>
        </execution>
    </executions>
</plugin>
<plugin>
于 2013-07-15T16:20:58.743 回答
3

这是一个老问题,但没有一个答案对我有用。将它们结合起来:

<filters>
    <filter>
        <artifact>*:*:*:*</artifact>
        <excludes>
            <exclude>META-INF/*.RSA</exclude>
            <exclude>META-INF/*.SF</exclude>
            <exclude>META-INF/*.DSA</exclude>
        </excludes>
    </filter>
</filters>
于 2019-07-23T17:49:05.477 回答