Chris Lieb
Chris Lieb

Reputation: 3836

Rename Gradle task

I have the desire to "wrap" the tasks generated by one of Gradle's plugins while retaining the name of the task that the users interact with. It seems like the best way to do this would be to rename the task generated by the plugin and then create the wrapper task using the same name.

At first glance, TaskContainer#replace seemed like the way to go, except it just creates a new, empty task using the original name, while I already have the task object I want to put at that name.

How can I "rename" a Gradle task so that I can create a new task using the original name while preserving the original task?

Upvotes: 6

Views: 3152

Answers (1)

Mark Vieira
Mark Vieira

Reputation: 13466

You could simply remove it from the task container while keeping a reference to it.

def oldTask = tasks.foo
tasks.remove(foo)

Upvotes: 7

Related Questions