欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

[插件]使用Gradle打可执行jar包

程序员文章站 2022-06-07 08:27:46
...

发现一个直接打出可执行jar包的gradle 插件

地址:

https://github.com/stigkj/gradle-executable-jar-plugin

 

用法:由于已经很明了,在此不做翻译了;

Executable Jar plugin for Gradle

The Executable Jar plugin creates an executable jar from your project with all its runtime dependencies embedded.

This means, when using this plugin in a build, you will get a artifact_-execjar.jar artifact than can be run like this:

java -jar artifact_name-execjar.jar

Usage

To use the executable jar plugin, include the following in your build script:

apply plugin: 'executable-jar'

// This is the class that starts your application
mainClass = 'the.class.that.has.Main'

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'net.nisgits.gradle:gradle-executable-jar-plugin:master-REL-6'
    }
}