how to export a executable jar in gradle, and this jar can run as it include reference libraries

前端 未结 5 2286
长情又很酷
长情又很酷 2020-12-25 10:15

how to export a executable jar in gradle, and this jar can run as it include reference libraries.

build.gradle

apply plugin: \'java\'

manifest.mainA         


        
5条回答
  •  抹茶落季
    2020-12-25 10:58

    I checked quite some links for the solution, finally did the below mentioned steps to get it working. I am using Gradle 2.9.

    Make the following changes in your build,gradle file :

    1. Mention plugin:

    apply plugin: 'eu.appsatori.fatjar'
    

    2. Provide the Buildscript:

    buildscript {
      repositories {
        jcenter()
       }
    
    dependencies {
      classpath "eu.appsatori:gradle-fatjar-plugin:0.3"
      }
    }
    

    3. Provide the Main Class:

    fatJar {
      classifier 'fat'
      manifest {
         attributes 'Main-Class': 'my.project.core.MyMainClass'
      }
      exclude 'META-INF/*.DSA', 'META-INF/*.RSA', 'META-INF/*.SF'
    }
    

    4. Create the fatjar:

    ./gradlew clean fatjar
    

    5. Run the fatjar from /build/libs/ :

    java -jar MyFatJar.jar
    

提交回复
热议问题