I have an issue where I need to exclude a specific file from a JAR, but cannot exclude the JAR altogether.
I have this JAR:
<dependency>
<groupId>org.acme.idm</groupId>
<artifactId>idm-browser</artifactId>
</dependency>
Adn this JAR contains (among other things) a file that must be excluded called:
real/form.ftl
I did some digging, and it looks like the Apache Shade plugin might work.
I tried using the Shade plugin with this configuration:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.3.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<filters>
<filter>
<artifact>org.acme.idm:idm-browser</artifact>
<excludes>
<exclude>real/form.ftl</exclude>
</excludes>
</filter>
</filters>
</configuration>
</execution>
</executions>
</plugin>
However, it does not exclude the file, and during the "mvn clean install", I get this message:
[INFO] --- shade:3.3.0:shade (default) @ artexch-ui ---
[INFO] No artifact matching filter org.acme.idm:idm-browser
[INFO] Replacing original artifact with shaded artifact.
Does anyone have any suggestions on how I can proceed?
To exclude files you have to define the filters configuration like that:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/MANIFEST.MF</exclude>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
...
</configuration>
</execution>
</executions>
</plugin>
In the filters there are given excludes for files in META-INF directory but of course you can define other things...