How do I add a task to main 'build' task in gradle
gradle, groovy, java
Solution
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.
Problem
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?