Search code examples
gradlejardependenciescommandline

Build Gradle JAR without dependencies


From command line, I need to build an executable jar without dependencies. The current "gradle build" command gives me a jar with dependencies.

Couldn't find this on StackOverflow. If it's a duplicate question, point me there. Thanks.


Solution

  • As you have SpringBoot plugin enabled, the default behavior is to build an executable jar (fat-jar) containing all dependencies, through thebootJar task.

    You can still generate a single "standard" jar if you need, this is explained in the documentation : Spring Boot Gradle plugin

    jar {
        enabled = true
    }
    bootJar {
        classifier = 'boot'
    }