This plugin provides the capability to package the artifact in an uber-jar, including its dependencies and to shade - i.e. rename - the packages of some of the dependencies.
The uberize:uberize goal should be exectued during the package phase. By default it will include all the runtime dependencies of your project in the uber jar when you run 'mvn package'.
Use the example below to add it to your project's pom.xml:
<project> ... <build> <plugins> <plugin> <groupId>org.fusesource.mvnplugins</groupId> <artifactId>maven-uberizer-plugin</artifactId> <version>1.14-SNAPSHOT</version> <executions> <execution> <phase>package</phase> <goals><goal>uberize</goal></goals> <configuration> <!-- Uncomment if you can exclude some dependencies... <artifactSet> <excludes> <exclude>jmock:jmock</exclude> </excludes> </artifactSet> --> <!-- Uncomment if want to move classes to new packages or aggregate and update resource files <transformers> <transformer implementation="org.fusesource.mvnplugins.uberize.transformer.PlexusComponents"/> <transformer implementation="org.fusesource.mvnplugins.uberize.transformer.ClassShader"> <relocations> <relocation> <pattern>org.apache.maven</pattern> <shadedPattern>org.fusesouce.maven</shadedPattern> <excludes> <exclude>org.codehaus.plexus.util.xml.Xpp3Dom</exclude> </excludes> </relocation> </relocations> <resources> <includes> <include>META-INF/plexus/components.xml</include> </includes> </resources> </transformer> </transformers> --> </configuration> </execution> </executions> </plugin> </plugins> </build> ... </project>
The goal supports many configuration options. For some examples, see:
Also see the uberize goal reference for the full listing of options.
The uberize plugin allows you to apply a sequence of transformers when the uber jar is being created. The transformer results stack. The next transformer in the configuration list will be transforming the results of the previous transformer.
Standard transformers are use to change or move entries in the uber jar.
Since multiple jar files are being merged to create the uber jar, is common that same jar entry or path will exists in two or more of the jars being merged. When this happens, the default behavior is to only use the content of the first jar which effectively causes you to loose the data in the subsequent jars. A warning will also be logged so that user do not get surprised.
To avoid loosing the data in those subsequent jars, this plugin allows you use an aggregation transformer. The specific transformer you use will depend on how you want the data merged. Since transformer results stack, you should position the aggregating transformers at the top of the the configuration list so that subsequent transformers process that aggregated results.