I have a project with a bunch of subprojects. Some of the subprojects are utility projects, and some of the projects are actual applications.
The "application" subprojects should all produce a jar file with a given main class etc. To solve this I've put the following in the parent build.gradle:
def configureApplication(project, mainClass) {
project.jar { ... }
}
and from each subproject's build.gradle, I call configureApplication(project, "my.main.Class")
Now I want to add a deploy
task to all application subproject's so that I can deploy all applications using ./gradlew deploy
. I've tried to mimic the above approach by putting this in the parent build.gradle:
def configureDeploy(project) {
project {
task deploy {
println "Deploying!"
}
}
}
But I'm running in to:
Could not find method call() for arguments [build_51pn93...closure3@334ebcaa] on project ':subproj'.
I've tried about a hundred other variations for the past hour without success.
Question: How do add tasks to some of the subprojects without repeating myself in each subproject's build.gradle? (Also, is using methods in the parent build.gradle a reasonable way of achieving this, or is there a more gradle idiomatic way of doing it?)