如何设置对这两个任务的依赖? preReleaseBuild
和preDebugBuild
我想做以下事情:
preReleaseBuild.dependsOn switchToRelease
preDebugBuild.dependsOn switchToDebug
但是我收到了这个错误:
Error:(251, 0) Could not find property 'preReleaseBuild' on project ':app'.
这两项任务显然存在,因为我在运行gradle assembleRelease
Zaks-MBP:androidapp zak$ gradle assembleRelease
Parallel execution is an incubating feature.
:analytics:compileJava
:app:gce2retrofit-release
:feed:compileJava
:gcm:compileJava
:backend:processResources UP-TO-DATE
:app:gce2retrofit-release UP-TO-DATE
:app:preBuild UP-TO-DATE
:app:preReleaseBuild UP-TO-DATE
:app:checkReleaseManifest
:app:preDebugBuild UP-TO-DATE
答案 0 :(得分:0)
需要使用afterEvaluate
afterEvaluate {
preReleaseBuild.dependsOn switchToRelease
preDebugBuild.dependsOn switchToDebug
}