Reputation: 1176
-
-- core (src/main/java)
-- dao (src/main/java)
-- models (src/main/java)
-- main (src/main/java)
What is the simpliest way to build one jar with main class
for multiple modules with Gradle and
copy all classes and all resources?
Upvotes: 0
Views: 1558
Reputation: 33436
Assuming that your project is modeled as a multi-project build you can create the following task in the build.gradle
file of your root project.
task uberJar(type: Jar, dependsOn: subprojects.assemble) {
subprojects.each { project ->
from project.configurations.archives.allArtifacts.files.collect { zipTree(it) }
}
manifest {
attributes 'Main-Class': '<your-main-class>'
}
}
You will also have to set the main class in your JAR manifest.
Upvotes: 2