Da ich des Öfteren Java-Projekte mit dem Build-System Gradle aufsetze und darin Fat-Jars erzeuge (ein ausführbares Java-Archive-Artefakt, bei dem alle Dependencies transitiv mit eingebunden werden) habe ich den Code-Snippet für Gradle hier einmal als Gedankenstütze hinterlegt.
task fatjar(type: Jar) {
dependsOn compileJava
manifest {
attributes "Main-Class": "com.timtrense.myproject.Main"
}
exclude 'META-INF/*.RSA', 'META-INF/*.SF', 'META-INF/*.DSA'
from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } }
duplicatesStrategy( DuplicatesStrategy.EXCLUDE )
with jar
}
task fatjartests(type: Jar) {
archiveClassifier.set "tests"
dependsOn compileJava
manifest {
attributes "Main-Class": "com.timtrense.myproject.BenchmarkMain"
}
exclude 'META-INF/*.RSA', 'META-INF/*.SF', 'META-INF/*.DSA'
from {
sourceSets.test.output
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
configurations.testCompile?.collect { it.isDirectory() ? it : zipTree(it) }
}
duplicatesStrategy( DuplicatesStrategy.EXCLUDE )
with jar
}