Quantcast
Channel: Gradle Forums - Latest posts
Viewing all articles
Browse latest Browse all 19888

Gradle 6.5 Create Java Executable Jar with Deps

$
0
0

You mean a Uber Jar or Fat Jar? The moment one of your dependencies is signed you get into trouble, you can pack all dependencies in one ZIP archive and have a single (executable) JAR in the root of the archive.

tasks.jar {
    manifest {
        attributes(            
            "Implementation-Title" to project.name,
            "Implementation-Version" to project.version,
            "Class-Path" to configurations.runtimeClasspath.files.map({ "${it.name}" }).joinToString(prefix = "lib/", separator = " lib/"),
            "Main-Class" to "com.foobar.Main"
        )
    }
}

tasks.register<Zip>("dist") {
    dependsOn(tasks["jar"])
    from(tasks.jar.get().archivePath)
    from(configurations.runtimeClasspath) {
        into("lib")
    }
}

Viewing all articles
Browse latest Browse all 19888

Trending Articles