When I try to add a task to the main build task with the following code:
rootProject.tasks.getByName('build').dependsOn mytask
It complains when I run gradle(w) build
with the output:
* Where:
Build file '...' line
: ...
* What went wrong:
A problem occurred evaluating project ':myapp'.
> Task with name 'build' not found in root project 'main'.
how do i add the task to the build task?
The problem is that your build has no build
task, at least at the time when above line gets evaluated. Usually, the build
task gets added by the java-base
plugin, which in turns gets applied by plugins such as java
, groovy
, or scala
. So make sure to apply one of these plugins first. Or, if you don't use any of them, declare your own build
task.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.