Let’s keep it very short;
gradle task is just like a method in any other programming language where we write bunch of instructions to get executed. A simple example would be :
On Android Studio, We can configure run configurations as per our need.
Let’s say we want to have a configuration which should do these couple of things i.e. generate apk, run all the test cases and generate coverage report. We can write respective task and feed the names of the tasks to the run configuration.
There are already default run configuration files are present. We can add ours as well.
An easy way could be to click on the option
"Open/edit Run/Debug configuration dialog"could and then choose
Edit Configurations...Configurations. Check below screenshot:
In above screenshot we can see couple of task have been added in “Tasks” section i.e. assembleTask myCustomTask1 and myCustomTask2.
Note that any new configuration created resides in
.idea/runConfigurations/ If needed we can open that xml and edit on IDE as well; here is a snippet showing what it looks like:
Now to run this configuration choose it from
"Open/edit Run/Debug configuration dialog". After choosing, just click on run button. A screenshot for reference:
In which all cases we would be using custom configuration ?
Mostly when we would need to run multiple tasks in a sequence. One example I gave above already. This is helpful when you want to automate whole build process in your local machine.
So hope you got the basic idea about gradle task and custom configuration. :)