我的Android项目中依赖任务的顺序存在问题。
这是我的app/build.gradle
文件的一部分:
task release
task archiveRelease(type: Copy) {
println 'copy apk and mapping files'
from './build/outputs/'
into "../releases/${rootProject.ext.configuration.version_code}_${rootProject.ext.configuration.version_name}"
include('apk/release/app-release.apk', 'mapping/release/mapping.txt')
rename('app-release.apk', "${rootProject.ext.configuration.package}_${rootProject.ext.configuration.version_code}_${rootProject.ext.configuration.version_name}.apk")
rename('mapping.txt', "mapping_${rootProject.ext.configuration.version_code}_${rootProject.ext.configuration.version_name}.txt")
}
project.afterEvaluate {
dependencyUpdates.dependsOn clean
assembleRelease.dependsOn clean
archiveRelease.mustRunAfter("assembleRelease")
release.dependsOn assembleRelease
}
但是,当我启动release
任务时,它会在copy apk and mapping files
的开头而不是assembleRelease
处打印$ ./gradlew release
Parallel execution with configuration on demand is an incubating feature.
> Configure project :app
copy apk and mapping files
。这是控制台输出:
archiveRelease
如何在构建完成后执行clearInterval()
?
答案 0 :(得分:1)
如果您想在使用以下内容调用发布任务时触发构建:
./gradlew release
:build => archiveRelease =>释放./gradlew build
:build => archiveRelease =>释放gradle:
task(release) {
doLast {
println 'release task'
}
}
task(archiveRelease) {
doLast {
println 'archiveRelease task'
}
}
build.finalizedBy release
archiveRelease.dependsOn build
release.dependsOn archiveRelease
所以在这种情况下./gradlew build
&如果这是你想要的,那么./gradlew release
就相同了。
但是如果你想要一个独立的release
任务来执行
./gradlew build
:build => archiveRelease =>释放./gradlew release
:archiveRelease =>释放gradle:
task(release) {
doLast {
println 'release task'
}
}
task(archiveRelease) {
doLast {
println 'archiveRelease task'
}
}
build.finalizedBy release
release.dependsOn archiveRelease