Ok, the Maven Resources Plugin and Assembly plugin didn't cut it, so I dug up a little more.
This seems to be doable with the Maven Shade plugin .
<build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-shade-plugin</artifactId> <version>1.4</version> <executions> <execution> <phase>package</phase> <goals> <goal>shade</goal> </goals> <configuration> <transformers> <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> <mainClass> </mainClass> <manifestEntries> <Class-Path>.</Class-Path> </manifestEntries> </transformer> </transformers> <filters> <filter> <artifact>org.something:SomeDependency</artifact> <excludes> <exclude>*.properties</exclude> </excludes> </filter> </filters> </configuration> </execution> </executions> </plugin> </plugins> </build>
So, inside <configuration> ... </configuration>
-tags, I defined two things: a transformer implementation that modifies the jar-manifest to be run, and use the current directory as the root of the classpath and exclude all files ending with with .properties from within the org.something: SomeDependency dependency.
The actual part of filtering is where you can exclude files that you donβt want to end up in the final shade-created jar. You can exclude files from all dependencies and the current project using <artifact>*:*</artifact>
inside a specific <filter>
, or you can select only a specific dependency using <artifact>dependcyGroupId:dependencyArtifact</artifact>
, for example <artifact>junit:junit</artifact>
, or even using wildcards for one or the other ( <artifact>*:junit</artifact>
). Excluded files are then defined inside <excludes>...</excludes>
-tags. Again, you can use exact file names or wildcards. This should make you go with your current problem, although I would suggest reading the documentation from the plugin site, because the shadow can do a lot more.
esaj
source share