The first time that maven-shade-plugin
runs, it:
- Uses foobar.jar as input
- Outputs foobar-shaded.jar
- Copies foobar.jar to original-foobar.jar
- Copies foobar-shaded.jar to foobar.jar
This allows the maven-install-plugin
to pick up the shaded JAR file and everyone is happy. Unfortunately, the second time you run the build the maven-shade-plugin
now picks up the output from the first run as the input of the second run and you will end up with a slew of errors (e.g. overlapping classes/resources).
What is the easiest way to fix the plugin's behavior so it can be run over an over again without a mvn clean
step?
The easiest workaround is to instruct the JAR plugin to run even if the source files did not change. This will overwrite the shaded JAR and the
maven-shade-plugin
will do the right thing: