I\'ve got a simple project in Gradle 4.6 and would like to make an executable jar of it. I\'ve tried shadow, gradle-fatjar-plugin, gradle-one
Based on the accepted answer, I needed to add one more line of code:
task fatJar(type: Jar) {
manifest {
attributes 'Main-Class': 'com.yourpackage.Main'
}
archiveClassifier = "all"
from {
configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
}
with jar
}
Without this additional line, it omitted my source files and only added the dependencies:
configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }