My pom.xml
contains the following to create a jar of my project with all dependencies.
Now I have a properties file in src/main/resources
which is necessary to run the application (and I want to use it from starting from the IDE), but I do not want to ship it in the created jar file, as the settings are maintained separately.
Question: How I can I get a file with all dependencies, but exclude those properties files?
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>make-jar</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<archive>
<manifest>
<mainClass>x.Main</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</execution>
If you want to stick with maven-assembly-plugin you can use an assembly descriptor file where you configure your filters, like in this section:
And in your maven configuration, pom.xml you specify the assemblu descriptor file, in the descriptors tag (distribution.xml is a file containing the section from above)
Also check this link maven-assembly
As specified by the
maven-assembly-plugin
documentation:Using the
maven-shade-plugin
you can have a fat jar (like using the assembly plugin) and solve similar issues of excluding files via configuration (no need of external assembly descriptor file).In your case, to exclude resources from assembled jars, you can use shade filters.
A simple configuration would look like:
In the example above, you can customize
file_pattern
or narrow down your filter in theartifact
element using yourmy.groupId:my.artifactId
.Note: the approach above is recommended when excluding files from external libraries, however you can still use the
maven-assembly-plugin
for excluding files from your own project via a custom assembly descriptor file.