一、Task移动Apk
tasks.register("notifyFileLocationChanged"){
dependsOn(tasks.getByName("deleteBuildFile"))
}
tasks.register<Delete>("deleteLastCopy") {
println("删除之前拷贝的文件")
delete(fileTree(layout.projectDirectory.dir("apks")).matching {
include("*.apk")
})
}
tasks.register<Copy>("copyAll"){
dependsOn(tasks.getByName("deleteLastCopy"))
println("拷贝文件")
duplicatesStrategy = DuplicatesStrategy.INCLUDE
val fileTree = fileTree(layout.projectDirectory.dir("app"))
fileTree.include("**/*.apk")
fileTree.exclude("build/*")
fileTree.forEach {
println(it.absolutePath)
from(it.absolutePath)
into(layout.projectDirectory.dir("apks"))
}
}
tasks.register<Delete>("deleteBuildFile") {
dependsOn(tasks.getByName("copyAll"))
println("删除构建文件")
val collection =layout.files(
layout.projectDirectory.dir("app/beta"),
layout.projectDirectory.dir("app/release"),
layout.projectDirectory.dir("app/release_32"),
layout.projectDirectory.dir("app/release_64")
)
collection.forEach {
delete(it.absolutePath)
}
二、运行
或者