Gradle复制apk到其他module下,并且重新命名
// 这块没有用,只是为了知道下边的project.afterEvaluate应该放在哪里
task clean(type: Delete) {
delete rootProject.buildDir
}
// 直接在project下的build.gradle文件下加下边代码就好
this.project.afterEvaluate { project ->
project.tasks.each { task ->
task.doLast {
def fromFile = "${project.getProjectDir().path}\\plugindemo1\\build\\outputs\\apk\\debug\\plugindemo1-debug.apk"
def intoFile = file('app').absolutePath + "\\src\\main\\assets\\"
try{
println("start copy ")
println("fromFile = " + fromFile)
println("intoFile = " + intoFile)
copy {
from fromFile
into intoFile
rename("plugindemo1-debug.apk","plugin.apk")
}
println("=======================build.dolast success====================")
}catch(Exception e) {
e.printStackTrace()
}
}
}
}