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?
Renaming files on copy The files used and generated by your builds sometimes don't have names that suit, in which case you want to rename those files as you copy them. Gradle allows you to do this as part of a copy specification using the rename() configuration.
The work that Gradle can do on a project is defined by one or more tasks. A task represents some atomic piece of work which a build performs. This might be compiling some classes, creating a JAR, generating Javadoc, or publishing some archives to a repository.
We describe the tasks and projects by using a Groovy script. You can run a Gradle build using the Gradle command. This command looks for a file called build. gradle.
Android Studio uses Gradle, an advanced build toolkit, to automate and manage the build process, while allowing you to define flexible custom build configurations. Each build configuration can define its own set of code and resources, while reusing the parts common to all versions of your app.
You could simply remove it from the task container while keeping a reference to it.
def oldTask = tasks.foo
tasks.remove(foo)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With