I'm trying to achieve the following distribution for my application, and I'm following this question as guideline
dist/
|-- application-1.0.jar
|-- conf/
|-- application.properties
|-- log4j.properties
|-- lib/
|-- *.jar
My src/main/resources
looks like following
resources/
|-- to.be.packaged.inside.jar
|-- to.be.packaged/
| |-- also
|-- conf/
|-- application.properties
|-- log4j.properties
Now, I want to exclude the whole conf folder from being packaged in the JAR (but placed in the target folder).
I tried the following configuration to maven-jar-plugin
<excludes>
<exclude>conf/*</exclude>
</excludes>
However, this still packages an empty conf folder inside the JAR. How do I exclude the folder and the content?
With
conf/*
you're only excluding the matching files, it doesn't match theconf
directory. By added<exclude>conf</exclude>
the directory will be excluded as well.However, you should ask yourself: should these files be available on the classpath? I would expect the conf-directory to be a directory in the project-root (i.e.
<project-root>/conf
), which also means a cleaner pom because you don't have to exclude resources.