The JarJar Plugin for Maven provides mojos to repackage dependencies inside a project artifact to avoid classpath conflicts. It uses code from the official JarJar project.
Jar Jar Links is a utility that makes it easy to repackage Java libraries and embed them into your own distribution. This is useful for two reasons:
This example is taken from the sisu-guice project, which embeds ASM and CGLIB.
<build> ... <plugin> <groupId>org.sonatype.plugins</groupId> <artifactId>jarjar-maven-plugin</artifactId> <executions> <execution> <phase>package</phase> <goals> <goal>jarjar</goal> </goals> <configuration> <includes> <include>asm:asm</include> <include>org.sonatype.sisu.inject:cglib</include> </includes> <rules> <rule> <pattern>org.objectweb.asm.**</pattern> <result>com.google.inject.internal.asm.@1</result> </rule> <rule> <pattern>net.sf.cglib.**</pattern> <result>com.google.inject.internal.cglib.@1</result> </rule> <keep> <pattern>com.google.inject.**</pattern> </keep> </rules> </configuration> </execution> </executions> </plugin> ...