`

将依赖的jar包inlining到另外一个jar包的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包中。

        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")
                                }
                        }
                }
        }
分享到:
评论

相关推荐

    Eclipse整合开发工具-基础篇

    Eclipse的目标是打造一个开放源代码的、可扩展的集成开发环境(IDE),为开发者提供一个灵活的平台来构建应用程序。 **1.2 开发开源软件** Eclipse不仅用于开发商业软件,也是开源软件开发的重要工具之一。通过其...

    Eclipse中文教程图文版

    3.2.2 Ant 执行时期(Ant Runtime) 3.3建置次序(Build Order) 3.4说明(Help) 3.4.1说明服务器(Help Server) 3.5自动更新(Install/Update) 3.6 Java 3.6.1外观(Appearance) 3.6.2类别路径变量(Classpath variables) ...

    Eclipse说明详见

    322 Ant 执行时期(Ant Runtime)79 33建置次序(Build Order)81 34说明(Help)82 341说明服务器(Help Server)83 35自动更新(Install/Update)84 36 Java84 361外观(Appearance)85 362类别路径变量(Classpath variables)...

    Eclipse 中文教程

    3.2.2 Ant 执行时期(Ant Runtime) 80 3.3建置次序(Build Order) 82 3.4说明(Help) 83 3.4.1说明服务器(Help Server) 84 3.5自动更新(Install/Update) 85 3.6 Java 86 3.6.1外观(Appearance) 86 3.6.2类别路径变量...

    eclipse 中文版教程

    322 Ant 执行时期(Ant Runtime) 109 33 建置次序(Build Order) 112 34 说明(Help) 113 341 说明服务器(Help Server) 115 35 自动更新(Install/Update) 116 36 Java 117 361 外观(Appearance) 118 362 类别...

    Eclipse中文教程文档

    3.2.2 Ant 執行時期(Ant Runtime) 108 3.3建置次序(Build Order) 111 3.4說明(Help) 112 3.4.1說明伺服器(Help Server) 114 3.5自動更新(Install/Update) 115 3.6 Java 116 3.6.1外觀(Appearance) 117 3.6.2類別路徑...

    Eclipse – 整合开发工具

    (Eclipse其中一个卖点就是它的扩充性) <br/> Eclipse这样功能完整且成熟的开发环境,是由蓝色巨人IBM所释出。IBM花了4千万美金来开发这个IDE(Integrated Development Environment)。第一版1.0在2001年11月...

    Eclipse从入门到精通.rar

    3.2.1 Ant 编辑器(Ant Editor) ................ 107 3.2.2 Ant 执行时期(Ant Runtime) ............. 109 3.3 建置次序(Build Order) 112 3.4 说明(Help)........... 113 3.4.1 说明服务器(Help Server)..........

    Eclipse中文使用教程

    3.2 Ant 3 .3建置次序 ( Build Order ) 3 .4说明 ( Help ) 3 .5自动更新 ( Install/ Update ) 3.6 Java 3 .7团队 ( Team ) 4 . Java 程序开发 4 .1建立 Java 项目 4 .2建立 Java 类别 4 .3程序代码完成功能 4 .4...

    Eclipse中文教程

    Eclipse中文教程三册全集 0.环境说明 .......................................................................3.2.1 Ant 编辑器(Ant Editor) ........................................ 107 3.2.2 Ant 执行时期...

    myeclipse教程

    0.环境说明...............................................................................................................................................................7 1.Eclipse简介...................

    Eclipse中文教程.pdf

    3、含文档结构目录,可以方便的跳转到对应章节 4、允许对文档注释和查找 目录 0.环境说明.......................................................................................................................

    Eclipse – 整合开发工具(基础篇)

    0.环境说明................................................................................................................................................................7 1.Eclipse简介.................

Global site tag (gtag.js) - Google Analytics