6

I'm having a problem in which I have a few third-party jars that I'm including in my project, and the third-party jars all have identically-named config files in the root directory of the jar file. When I execute mvn package to construct one jar (for deployment) using maven-assembly-plugin, the resulting jar file only contains one config file in the root directory, and it has the contents of just one of the config files. Then, when I run my application from the "super jar", errors occur due to the missing configs. I thought using maven-shade-plugin would help, since it appeared that it supported concatenating such files, but this approach didn't work (the conflicting files were not appended, and moreover I received new warnings about duplicate imports of apache commons libraries that didn't occur before).

What is the best way to handle this in the most automatic and maintainable way?

jonderry
  • 23,013
  • 32
  • 104
  • 171

1 Answers1

0

maven-shade-plugin can help with this indeed, but you need to properly configure it to use resource transformers: see https://maven.apache.org/plugins/maven-shade-plugin/examples/resource-transformers.html
There are specialized transformers available for common java stuff (like SPI files in META-INF/services and manifest files) that require just enabling, as well as more generic transformers that need to be told exactly what to do.

maven-assembly-plugin can also probably do similar stuff, but it would require to write your own assembly descriptor. See this answer in a similar question.

morgwai
  • 2,513
  • 4
  • 25
  • 31