13

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?

Dzmitry Kashlach
  • 404
  • 1
  • 5
  • 16

3 Answers3

14

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>
Pokechu22
  • 4,984
  • 9
  • 37
  • 62
Tim Veil
  • 206
  • 2
  • 4
  • 1
    It doesn't exclude `META-INF/ECLIPSE.SF` and `META-INF/ECLIPSE.RSA`. What's even more interesting is that I'm not using eclipse at all, I'm using Intellij. – Searene Nov 29 '16 at 02:04
  • This allowed me to remove a pesky license.txt file from the jar by just including the line LICENSE.txt – JWCompDev Mar 31 '17 at 04:43
8

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>
Joe Coder
  • 4,498
  • 31
  • 41
  • 1
    Tried that (without ManifestResourceTransformer), didn't work for me, the BCKEY.* files are still there. I've tried artifact `*:*:*:*` too. It's an old answer, has Maven syntax changed since? – Seva Alekseyev Oct 26 '16 at 18:24
  • 1
    @SevaAlekseyev, did you find a solution. Above solution doesn't work for me? – tryingToLearn Mar 15 '18 at 06:58
  • Moving configuration out of executions did the trick for me https://stackoverflow.com/a/34740005/673826 – mlt Jan 31 '21 at 10:53
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>
Joe Driscoll
  • 31
  • 1
  • 3