Skip to content

Instantly share code, notes, and snippets.

@Lien
Created October 25, 2013 07:03
Show Gist options
  • Save Lien/7150489 to your computer and use it in GitHub Desktop.
Save Lien/7150489 to your computer and use it in GitHub Desktop.
Simple gradle task to create a fatJar that includes all dependencies except for specific jars. Snippet below doesn't include android.jar file.
task fatJar(type: Jar, dependsOn: 'compileJava') {
from {
sourceSets.main.output.classesDir
}
// Add all dependencies except for android.jar to the fat jar
from {
configurations.compile.findAll {
it.getName() != 'android.jar'
}.collect {
it.isDirectory() ? it : zipTree(it)
}
}
archiveName = 'fatJar.jar'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment