Executable fat jars are easy to deploy and upgrade, and don't need wrapper scripts to pull in the classpath. You can use the Gradle fatjar plugin to create executable, self-contained jars in Gradle, akin to the Shade plugin for Maven -
apply plugin: 'fatjar'
buildscript {
dependencies {
classpath 'eu.appsatori:gradle-fatjar-plugin:0.1.3'
}
}
The fatjar task is set up as follows
fatJar {
classifier 'fat'
manifest {
attributes 'Main-Class': 'net.amadan.service.ServiceMain'
}
exclude 'META-INF/*.DSA', 'META-INF/*.RSA', 'META-INF/*.SF'
}
and called like this
./gradlew clean fatjar
This is useful for bundling jobs for Storm as an alternative to maven packaging, or for building Dropwizard backed services.
Note, the fatjar plugin doesn't currently put versioning info into the jar name.
The executable-jar plugin also exists for Gradle but it does some kind of loader trick when it calls your main. This may cause Guice to freak out, and may be unpredictable for anything that isn't expecting classloader hacks, or requires classpath/reflection scanning (eg Jersey).