When you build a fat jar using the maven-shade-plugin, there might be conflicts between files at the same path but originating from different dependencies. Similarly, it becomes hard to distinguish the origin of various dependency-specific files located at the root of the individual dependencies (LICENSE.txt, native libraries, ...) when they are placed side-by-side at common locations in the shaded jar.
maven-shade-plugin itself and the similar jarjar-maven-plugin appear to provide functionality for automatically relocating classes, but not other files from the dependencies, such as those seen in the following example:
Example of current messy structure
/
- NOTICE
- magic.gz
- LICENSE.txt
- LICENSE
- asm-license.txt
/ META-INF
- LICENSE.TXT
- about.html
/ com.some.library
<class files>
/ com.some.other.library
<class files>
/ com.some.third.library
<class files>
This is an example from a project I just started. None of the files above were added by me, but all come from various popular third party libraries I'm using. I would like to clean up this mess by having Maven reorganize files in a common package structure like in the following example:
Example of desired clean structure
/
/ com.some.library
<class files>
- NOTICE
- LICENSE
/ META-INF
- about.html
/ com.some.other.library
<class files>
- magic.gz
- LICENSE.txt
/ com.some.third.library
<class files>
- asm-license.txt
/ META-INF
- LICENSE.TXT
I have many dependencies, so I don't consider writing dependency-specific filters/relocators/... with hard-coded filenames a good solution to this problem.
How do you organize all files from dependencies in your shaded jar automatically? Ideally by relocating all files from a dependency inside a subfolder named after the dependency.