Skip to content

Instantly share code, notes, and snippets.

@prameshbhattarai
Created July 24, 2019 06:46
Show Gist options
  • Save prameshbhattarai/b3e98d558121fa2c3043e483b1220fe9 to your computer and use it in GitHub Desktop.
Save prameshbhattarai/b3e98d558121fa2c3043e483b1220fe9 to your computer and use it in GitHub Desktop.
creating jar file with dependencies in gradle
// creating jar file with all dependencies
jar {
manifest {
attributes "Main-Class": "PATH_TO_MAIN_CLASS"
}
from {
// filters only existing and non-empty dirs
sourceSets.main.runtimeClasspath
.filter { (it.isDirectory() && it.listFiles().length > 0) || it.isFile() }
.collect { it.isDirectory() ? it : zipTree(it) }
}
}
// then simply run
// gradle clean jar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment