Apache Maven Shade Plugin – Relocating Classes (original) (raw)
If the uber JAR is reused as a dependency of some other project, directly including classes from the artifact's dependencies in the uber JAR can cause class loading conflicts due to duplicate classes on the class path. To address this issue, one can relocate the classes which get included in the shaded artifact in order to create a private copy of their bytecode:
... org.apache.maven.plugins maven-shade-plugin 3.6.0 package shade org.codehaus.plexus.util org.shaded.plexus.util org.codehaus.plexus.util.xml.Xpp3Dom org.codehaus.plexus.util.xml.pull.* ...This instructs the plugin to move classes from the package org.codehaus.plexus.util
and its subpackages into the package org.shaded.plexus.util
by moving the corresponding JAR file entries and rewritting the affected bytecode. The class Xpp3Dom
and some others will remain in their original package.
It's also possible to narrow the pattern with the include
tag: