0

On my pom.xml I have the following <plugin> section:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.1</version>
    <configuration>
        <source>1.8</source>
        <target>1.8</target>
    </configuration>
</plugin>
<plugin> 
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-dependency-plugin</artifactId>
    <version>2.8</version>
        <executions>
            <execution>
                <id>copy-dependencies</id>
                <phase>prepare-package</phase>
                <goals>
                    <goal>copy-dependencies</goal>
                </goals>
                <configuration>
                    <excludeScope>system</excludeScope>
                    <excludes>META-INF/*.SF</excludes>
                    <excludes>META-INF/*.DSA</excludes>
                    <excludes>META-INF/*.RSA</excludes>
                    <excludeGroupIds>junit,org.mockito,org.hamcrest</excludeGroupIds>
                    <outputDirectory>${project.build.directory}/classes/lib/</outputDirectory>
                     <includeScope>runtime</includeScope>
                 </configuration>
             </execution>
         </executions>
</plugin>

But, whenever I build the project with a mvn clean install -U, some .SF, .DSA and .RSA are copied to the built jar file and I need to remove them manually.

How to correct this?

gtludwig
  • 5,411
  • 10
  • 64
  • 90
  • 1
    __ does not exclude files inside dependencies, but dependencies. – Tome Nov 28 '16 at 12:53
  • 1
    The `copy-dependencies` goal you have... copies dependencies. It does not remove any files from anywhere. What you want is probably the Shade plugin, see http://stackoverflow.com/questions/17658831/how-can-i-exclude-dsa-and-sf-files-from-shaded-jar – Tunaki Nov 28 '16 at 12:53
  • @Tunaki _excludes_ will remove the those files from inside the dependencies when it does the copy – geometrikal Oct 30 '21 at 13:02

1 Answers1

2

The correct usage of tag <excludes> is following:

<excludes>META-INF/*.SF,META-INF/*.DSA,META-INF/*.RSA</excludes>