• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

musketyr/gradle-fatjar-plugin: Gradle FatJAR Plugin

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

musketyr/gradle-fatjar-plugin

开源软件地址(OpenSource Url):

https://github.com/musketyr/gradle-fatjar-plugin

开源编程语言(OpenSource Language):

Groovy 100.0%

开源软件介绍(OpenSource Introduction):

Gradle FatJar Plugin

WARNING: This plugin is no longer under active development. Please, migrate to Gradle Shadow Plugin which provides similar functionality.

Gradle FatJar Plugin allows you to create JAR file with all dependencies bundled inside. It handles files in META-INF/services directory gracefully by merging them. It also allows you to create slim WAR file which contains only JAR with dependencies. Classes are also bundled into the JAR instead of putting them into WEB-INF/classes.

Build Status

Download

Plugin is hosted on Bintray. You can easily add plugin to your build script using following configuration

Installation

buildscript {
    repositories {
        jcenter()
    }

    dependencies {
        classpath 'eu.appsatori:gradle-fatjar-plugin:0.3'
    }
}

apply plugin: 'eu.appsatori.fatjar'

Tasks

Note: regular jar and war tasks are not replaced by this plugin. You can still use them. Don't forget that you need to configure fatJar and slimWar tasks if you want to modify generated manifest or exclude files not jar or war ones.

fatJarPrepareFiles

Explodes all JARs into the stage directory and merges all files needed such as those in META-INF/services.

fatJar

Creates the JAR with all dependencies bundled.

This is regular Jar task so you can e.g. customize the manifest as described in Jar Task DSL. You can for example exclude files from being jared.

fatJar {
    exclude 'META-INF/*.DSA'
}

slimWar

Bundles all output classes into JAR with dependencies and place it into WEB-INF/lib directory of the newly created WAR file.

This is regular War task so you can e.g. customize the web.xml file as described in War Task DSL. You can for example exclude files which you don't want to copy into the final WAR.

slimWar {
    exclude('WEB-INF/gtpl/', 'WEB-INF/groovy/')
}

Customization

File Merge

You can specify additional files to be merged using Ant-style pattern and include method on fatJarPrepareFiles task.

fatJarPrepareFiles {
  include 'META-INF/spring.handlers'
  include 'META-INF/spring.schemas'
}

Excluding files

You can specify files which should not be copied to fat jar using Ant-style pattern and exclude method on fatJarPrepareFiles task.

fatJarPrepareFiles {
  exclude 'META-INF/my.properties'
}

Exclude JARs

If you need to keep some JARs out of the JAR with dependencies you can specify extended property fatJarExclude on particular dependency. All excluded JARs will be placed in WEB-INF\lib directory if slimWar task is called.

dependencies {
  compile 'eu.appsatori:pipes:0.6.1', {
    ext {
      fatJarExclude = true
    }
  }
}

Create executable jar

Adapted from http://stackoverflow.com/questions/23738676/how-to-specify-main-class-when-using-fatjar-plugin-in-gradle-build

Replace

apply plugin: 'eu.appsatori.fatjar'

with

task fatJar(type: Jar) {
    baseName = project.name + '-all'
    from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
    with jar
    manifest {
        attributes 'Implementation-Title': 'Gradle Quickstart', 'Implementation-Version': version
        attributes 'Main-Class': 'com.organization.project.package.mainClassName'
    }
}



鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
grails/grails-gradle-plugin-archived发布时间:2022-06-14
下一篇:
szpak/gradle-pitest-plugin: Gradle plugin for PIT Mutation Testing发布时间:2022-06-14
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap