Extending a Task Action

I need to extend one of the tasks in the Android-plugin. But stick to some troubles. I have already understood that overwrite is not working. Don’t understand why it is still in documentation.

I have found a solution to change task logic it looks like this:

<task_name> {
    actions = []
    doLast {
   println 'I have changed task execution'
 }
}

But for which task type this construction works ? For example in java-plugin it works for build tasks, like: “jar”, “assemble” But it is a problem to overwrite task “help” for example. It imidiately will show an error:

Could not find method help() for arguments [build_7ujgmls5lue56vvhkoimm8i4i$_run_closure2@1817fe89] on root project 'experiment'.

It should work for all tasks, except for a few built-in tasks like ‘help’. It’s not a good practice though, and should only be used as a last resort.

  1. How can I understand which tasks can be remade and which can not?

  2. Agree that it is not a good solution, a little dirty though. But I don’t know a better solution to insert my task into android plugin execution sequence. Sure I can write lot’s of dependancies for each task, but that seems even worser solution.

  1. How can I understand which tasks can be remade and which can not?

  2. Agree that it is not a good solution, a little dirty though. But I dont know a better solution to insert my task into android plugin execution sequence. Sure I can write lot’s of dependancies for each task, but that seems even worser solution.

Should work for all tasks except for those shown by ‘gradle tasks’ for an empty build script. Note that replacing task actions can lead to incorrect task dependencies and incorrect up-to-date behavior. Whenever you can, use a new task and ‘dependsOn’ instead.