https://code.google.com/p/jarjar/
?
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:
spring中https://github.com/spring-projects/spring-framework/blob/3.2.x/build.gradle构建spring-core包,将asm和cglib包inling到spring-core包中。
????????class="n">task asmRepackJar(type: Jar) { repackJar -> ????????????????repackJar.baseName = "spring-asm-repack" ????????????????repackJar.version = asmVersion ? ????????????????doLast() { ????????????????????????project.ant { ????????????????????????????????taskdef name: "jarjar", classname: "com.tonicsystems.jarjar.JarJarTask", ????????????????????????????????????????classpath: configurations.jarjar.asPath ????????????????????????????????jarjar(destfile: repackJar.archivePath) { ????????????????????????????????????????configurations.asm.each { originalJar -> ????????????????????????????????????????????????zipfileset(src: originalJar) ????????????????????????????????????????} ????????????????????????????????????????rule(pattern: "org.objectweb.asm.**", result: "org.springframework.asm.@1") ????????????????????????????????} ????????????????????????} ????????????????} ????????} ? ????????task cglibRepackJar(type: Jar) { repackJar -> ????????????????repackJar.baseName = "spring-cglib-repack" ????????????????repackJar.version = cglibVersion ? ????????????????doLast() { ????????????????????????project.ant { ????????????????????????????????taskdef name: "jarjar", classname: "com.tonicsystems.jarjar.JarJarTask", ????????????????????????????????????????classpath: configurations.jarjar.asPath ????????????????????????????????jarjar(destfile: repackJar.archivePath) { ????????????????????????????????????????configurations.cglib.each { originalJar -> ????????????????????????????????????????????????zipfileset(src: originalJar) ????????????????????????????????????????} ????????????????????????????????????????// repackage net.sf.cglib => org.springframework.cglib ????????????????????????????????????????rule(pattern: "net.sf.cglib.**", result: "org.springframework.cglib.@1") ????????????????????????????????????????// as mentioned above, transform cglib"s internal asm dependencies from ????????????????????????????????????????// org.objectweb.asm => org.springframework.asm. Doing this counts on the ????????????????????????????????????????// the fact that Spring and cglib depend on the same version of asm! ????????????????????????????????????????rule(pattern: "org.objectweb.asm.**", result: "org.springframework.asm.@1") ????????????????????????????????} ????????????????????????} ????????????????} ????????}