问题
I have a section in pom.xml
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
</excludes>
</filter>
</filters>
I want to exclude *.SF and *.DSA files from final jar. But I get the following message:
[INFO] No artifact matching filter *:*
and files are not excluded. Does anyone know how to overcome it?
回答1:
I had the same problem. It was fixed by making my artifact selector more specific, e.g.
<artifact>bouncycastle:*</artifact>
The entire block looks like this:
<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>
回答2:
Actually you can do global filtering without needing to specify group id, you just need to use the correct wildcard syntax. If you want to exclude all *.RSA files from your jar, for example, specify the artifactId as *:*:*:*
<filters>
<filter>
<artifact>*:*:*:*</artifact>
<excludes>
<exclude>*.RSA</exclude>
</excludes>
</filter>
</filters>
回答3:
This is an old question, but neither of the answers worked for me. Combining them did:
<filters>
<filter>
<artifact>*:*:*:*</artifact>
<excludes>
<exclude>META-INF/*.RSA</exclude>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
</excludes>
</filter>
</filters>
来源:https://stackoverflow.com/questions/17658831/how-can-i-exclude-dsa-and-sf-files-from-shaded-jar