gradle fatjar

ht‮w//:spt‬ww.lautturi.com
gradle fatjar

To create a "fat jar" or "uber jar" using Gradle, you can use the Shadow plugin. This plugin creates a single jar file that includes all the dependencies of your project, along with the compiled class files and resources.

Here's an example of how you can use the Shadow plugin in your Gradle build file:

buildscript {
  repositories {
    mavenCentral()
  }
  dependencies {
    classpath 'com.github.jengelman.gradle.plugins:shadow:6.1.0'
  }
}

apply plugin: 'com.github.johnrengelman.shadow'

jar {
  manifest {
    attributes 'Main-Class': 'com.example.Main'
  }
}

shadowJar {
  // optional configuration options
}

This configuration will create a jar file called shadow.jar in the build/libs directory, which includes all the dependencies of the project. You can then run the shadowJar task to create the fat jar:

gradle shadowJar

You can also customize the shadowJar task by setting various options, such as the name and location of the fat jar, the dependencies to include or exclude, and the classifier to use.

For more information about the Shadow plugin and the options that it supports, you can refer to the plugin's documentation.

Created Time:2017-11-01 12:05:03  Author:lautturi