I'm using Maven to build a Java project, and I've got a couple files, CHANGELOG
and LICENSE
, that I'd like to copy to the META-INF
directory inside the JAR file.
So far what I've got working is the following:
<build>
<resources>
<resource>
<directory>${project.basedir}</directory>
<includes>
<include>CHANGELOG</include>
<include>LICENSE</include>
</includes>
<targetPath>META-INF</targetPath>
</resource>
</resources>
<plugins>
...
but that also copies those two files to the classes/META-INF
directory when compiling.
So I'd like the files to be included in the JAR file, but nowhere else. Is there a way to do this?
You don't need to specify any custom maven configuration to address your need.
In src/main/resources
, simply create a META-INF
folder and place your files here.
In this way, you could find them in the META-INF
folder of the built JAR.
Besides, you should remove the <resource>
element you added in the pom.xml
since it changes the default resource folder to the root of the project instead of the default src/main/resources
.
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