You can use the following code.
jar {
manifest {
attributes(
'Main-Class': 'com.package.YourClass'
)
}
from {
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
}
}
Be sure to replace com.package.YourClass
with the fully qualified class name containing static void main( String args[] )
.
This will pack the runtime dependencies. Check the docs if you need more info.