How can I exclude *.DSA and *.SF files from shaded jar?

后端 未结 3 2135
我在风中等你
我在风中等你 2020-12-16 16:15

I have a section in pom.xml

 
   
      *:*
         
            

        
相关标签:
3条回答
  • 2020-12-16 16:45

    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>
    
    0 讨论(0)
  • 2020-12-16 16:48

    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>
    
    0 讨论(0)
  • 2020-12-16 17:04

    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>
    
    0 讨论(0)
提交回复
热议问题