I use Maven
to build a JAR
. When I check the JAR
, I see a maven
folder inside the META-INF
folder. I want it to be excluded from the build. My current build code in the pom.xml
looks like this:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>Libraries</classpathPrefix>
<mainClass>com.company.Main</mainClass>
</manifest>
<manifestEntries>
<Built-By>Me</Built-By>
</manifestEntries>
</archive>
<!-- <excludes>
<exclude>META-INF/maven/**</exclude>
</excludes> -->
</configuration>
</plugin>
<!-- ...more plugins... -->
</plugins>
</build>
I read that using the exclude
tags allows you to exclude something but it doesn't work. Maybe this only refers to local files/folders? The maven
folder is not part of the source, it's just added by Maven
.
This answer kind of works but uses a different artifact hence a 2nd JAR
is generated when I paste it into my pom.xml
. I want to use my current build code and exclude the maven
folder like described above. How can it be done using maven
build rules?
The maven-jar-plugin
uses the maven-archiver
to handle packaging. It provides the configuration addMavenDescriptor
, which is true
by default. Setting it to false
should remove the META-INF/maven
directory.
...
<archive>
<addMavenDescriptor>false</addMavenDescriptor>
....
</archive>
You can find the reference here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With