One-Jar: package a Groovy application together with its dependency Jars into a single executable Jar file

(Peter Crosbie) #1

Hi, I’m new to Gradle and looking for a plugin or recipe to create a build.gradle that will create a single executable jar file from my groovy project (which has a mix of groovy and java). lists a plugin OneJar ( but it no longer appears to be available (or at least is failing to download from repo).

There is a sourceforge project One-Jar ( that can be run from Ant script so presumably this can in turn be called from Gradle. However, before I plunge off in this direction I wanted to check if more experienced folks had better ideas.

(While I appreciate create big fat jars isn’t necessarily best practice it is extremely convenient for a lot of the work we do with small data handling utilities we use around the desk).

Can anyone point me in the right (or better) direction?

Many thanks, peter

(sonosen) #2

Try this in your build.gradle:

jar {
         from {
            configurations.compile.collect {
                it.isDirectory() ? it : zipTree(it)

(Peter Niederwieser) #3

You’ll want ‘configurations.runtime’. Also you’ll probably want to set the ‘Main-Class’ attribute in the Jar manifest.

(Peter Niederwieser) #4

For small and self-contained apps, Gradle’s application plugin is a good fit.