将依赖的jar包inlining到另外一个jar包的ant插件_JAVA_编程开发_程序员俱乐部

中国优秀的程序员网站程序员频道CXYCLUB技术地图
热搜:
更多>>
 
您所在的位置: 程序员俱乐部 > 编程开发 > JAVA > 将依赖的jar包inlining到另外一个jar包的ant插件

将依赖的jar包inlining到另外一个jar包的ant插件

 2013/11/4 15:35:43  wiflish  程序员俱乐部  我要评论(0)
  • 摘要:https://code.google.com/p/jarjar/JarJarLinksisautilitythatmakesiteasytorepackageJavalibrariesandembedthemintoyourowndistribution.Thisisusefulfortworeasons:Youcaneasilyshipasinglejarfilewithnoexternaldependencies
  • 标签:插件 一个 Ant

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:

  • You can easily ship a single jar file with no external dependencies.
  • You can avoid problems where your library depends on a specific version of a library, which may conflict with the dependencies of another library.

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") ????????????????????????????????} ????????????????????????} ????????????????} ????????}
上一篇: 面授竞赛试题 下一篇: 没有下一篇了!
发表评论
用户名: 匿名