Reputation: 379
Hi I have multi project gradle setup
-root_project
|-sub_project1
|-sub_project2
|-sub_project3
All works great but one thing drives me crazy. In my build script:
defaultTasks 'build' <- this works just fine
task buildroom (description: 'This task is invoked by build room script, invokes default task plus publishes artifacts') {
// dependsOn('build') <-- this doesn't work
// alternative
dependsOn(":sub_project1:build")
dependsOn(":sub_project2:build")
when i call from command line 'gradlew' <- default task gets executed
when i call from command line 'gradlew tasks' <- task under 'all task runnable from root project' i see 'build'
but when i try to add dependsOn('build'), dependsOn(':build') or dependsOn(':root:build') it tells me
What went wrong: Execution failed for task ':tasks'.
Could not determine the dependencies of task ':buildroom'.
'base' plugin adds 'assemble', and 'clean' task but not build...
any tips?
Upvotes: 10
Views: 21344
Reputation: 123910
The build
task is declared by the java-base
plugin. It's likely that your root project doesn't (directly or indirectly) apply java-base
and therefore doesn't have a build
task. This is why dependsOn("build")
, which adds a task dependency on a task named build
in the same project, eventually causes an error. defaultTasks
is different in that:
dependsOn
also accepts task paths and Task
objects). Upvotes: 13