2015-11-03 82 views

回答

1

一种方法是定义一个依赖于包装任务你想运行的任务。 例如添加以下到根的build.gradle:

task cleanAndTestAll(dependsOn: [ clean, ':unit:test', ':app:connectedAndroidTestPlayDebug']) { } 

该任务会触发其他两个任务。并给出像输出如下:

15:31:38: Executing external task 'cleanAndTestAll'... 
:clean 
:app:connectedAndroidTestPlayDebug 
:unit:test 
:cleanAndTestAll 

BUILD SUCCESSFUL 

如果要执行任务之间的排序,你可以这样做: https://docs.gradle.org/current/userguide/more_about_tasks.html

task cleanAndTestAll(dependsOn: [clean, ':unit:test', ':app:connectedAndroidTestPlayDebug']) { } 
tasks.getByPath(':app:connectedAndroidTestPlayDebug').mustRunAfter tasks.getByPath(':unit:test') 

在详细了解gradle这个任务

+0

我最终到达了解决方案,但你更快;)谢谢! – AlvaroSantisteban