Skip to content

Instantly share code, notes, and snippets.

@lucacesari
Created September 19, 2014 06:45
Show Gist options
  • Save lucacesari/27f321c0356f63017ea8 to your computer and use it in GitHub Desktop.
Save lucacesari/27f321c0356f63017ea8 to your computer and use it in GitHub Desktop.
Create a fat jar with Gradle
ext {
vendor = "vendor"
version = "42.0"
basename = "foo"
mainClassName = "bar.foo.mainClass"
}
dependencies {
compile project(':my_other_project')
compile 'ch.qos.logback:logback-classic:1.1.1'
compile fileTree(dir: "../libs", includes: ['*.jar'])
}
jar {
baseName = basename
manifest {
attributes "Manifest-Version" : "1.0"
attributes "Created-By" : vendor
attributes "Specification-Title" : basename
attributes "Specification-Version" : version
attributes "Specification-Vendor" : vendor
attributes "Implementation-Title" : basename
attributes "Implementation-Version" : version
attributes "Implementation-Vendor" : vendor
attributes 'Main-Class': mainClassName
attributes 'Class-Path': '.'
}
from (configurations.compile.files.collect { it.isDirectory() ? it : zipTree(it) } ) {
exclude "META-INF/*.SF"
exclude "META-INF/*.DSA"
exclude "META-INF/*.RSA"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment