Reputation: 2560
I want to edit gradle task named installDebug. Where is the task (or script) located? Maybe this script is located in binary code and I'm not change that?
Really, I want run edit something option for adb
.
Example: My task must contain:
What I should do: Edit debugTask if possible? Or edit build.grade and make own task script?
Upvotes: 6
Views: 4128
Reputation: 84756
All the tasks are located in build.gradle
script itself or in the plugin that is applied at the beginning of the script.
installDebug task is provided by as far as I remember android plugin. Every single task consists of actions that are executed sequentially. Here's the place to start.
You can extend a task adding action to the beginning of at the end of internal actions list.
So:
//this piece of code will run *adb connect* in the background
installDebug.doFirst {
def processBuilder = new ProcessBuilder(['adb', 'connnect', '192.168.1.2:5555'])
processBuilder.start()
}
installDebug.doLast {
//Do something, like - adb then open apk on my adb server..
}
Here, two actions were added to installDebug task. If you run gradle installDebug
, first action will be run, then the task itself and finally the second action that is defined. That's all in general.
Upvotes: 4
Reputation: 677
You can add a task to your build.gradle, and call it in command line. This is what I have done :
task adbConnect(type: Exec) {
commandLine 'adb', 'connect', '192.168.200.92'
}
then I call gradle adbConnect connectedCheck, but you can use gradle adbConnect debugInstall
Upvotes: 2