Skip to content

Instantly share code, notes, and snippets.

@bibarsov
Last active February 27, 2019 22:32
Show Gist options
  • Save bibarsov/3b17aa8af7a98c922ccff4e1a1418c27 to your computer and use it in GitHub Desktop.
Save bibarsov/3b17aa8af7a98c922ccff4e1a1418c27 to your computer and use it in GitHub Desktop.
Export Jar with dependencies (Gradle)
task fatJar(type: Jar) {
manifest {
attributes 'Implementation-Title': 'Gradle Jar File Example',
'Implementation-Version': version,
'Main-Class': 'com.example.Main'
}
baseName = project.name + '-all'
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
with jar
}
#Later versions
task fatJar(type: Jar) {
manifest {
attributes(
'Implementation-Title': '...',
'Implementation-Version': version,
'Main-Class': 'Main'
)
}
baseName = project.name
from {
configurations.runtimeClasspath.collect {
it.isDirectory() ? it : zipTree(it)
}
}
with jar
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment