def fileArray = []
//遍历输出文件
android.applicationVariants.all { variant ->
variant.outputs.all { output ->
def outputFile = output.outputFile
if (outputFile != null && outputFile.name.endsWith('release.apk')) {
def fileName = "xxx_${defaultConfig.versionName}_${defaultConfig.versionCode}" +
"_${variant.productFlavors[0].name}.apk"
outputFileName = fileName
//往数组添加输出的文件路径
fileArray.add(outputFile.parentFile.absolutePath + File.separator + fileName)
}
}
build {
//build命令加入这段代码
doLast() {
//遍历文件数组并进行操作
forEachFile(fileArray)
}
}
//assembleRelease命令加入这段代码
afterEvaluate {
assembleRelease.doLast {
//遍历文件数组并进行操作
forEachFile(fileArray)
}
}
def forEachFile(fileArray) {
fileArray.forEach { file ->
//遍历进行文件操作
rename_andd_moveout_apk(file)
}
}
def rename_andd_moveout_apk(orignalFile) {
def intoFile = rootDir.parentFile.getAbsolutePath()+File.separator+"apk"
copy {
from orignalFile
into intoCodeFile
rename("${android.defaultConfig.versionName}_
${android.defaultConfig.versionCode}_", "")
}
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有