task stopTomcat(type:Exec) {
workingDir '../tomcat/bin'
//on windows:
commandLine 'cmd', '/c', 'stop.bat'
//on linux
commandLine './stop.sh'
//store the output instead of printing to the console:
standardOutput = new ByteArrayOutputStream()
//extension method stopTomcat.output() can be used to obtain the output:
ext.output = {
return standardOutput.toString()
}
}
- 我实际的操作是app 每次启动的时候,在 gradle 中执行clear 命令,清除 app的数据,
task clearAllData(type: Exec) {
def clearDataCommand = ['adb', 'shell', 'pm', 'clear', 'com.jar.media_player_five']
commandLine clearDataCommand
}