加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
release.gradle 4.98 KB
一键复制 编辑 原始数据 按行查看 历史
skygge 提交于 2020-04-10 20:34 . 升级了阿里SDK
/**
* 该脚本是为了同时打出国内版和海外版,使用 ./gradlew build 命令可以打出四个apk release debug releaseOversea debugOversea
*
*
*/
buildscript {
repositories {
mavenLocal()
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
}
}
android{
signingConfigs {
debug {
storeFile file("xjjsiterwell.jks")
storePassword '123456'
keyAlias '123456'
keyPassword '123456'
}
release {
storeFile file("xjjsiterwell.jks")
storePassword '123456'
keyAlias '123456'
keyPassword '123456'
}
}
buildTypes {
releaseOversea {
minifyEnabled true
buildConfigField "String", "BUILD_COUNTRY","\"OVERSEA\"" //海外
signingConfig signingConfigs.release
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}//debug 默认不开混淆
debugOversea {
minifyEnabled false
buildConfigField "String", "BUILD_COUNTRY","\"OVERSEA\""
signingConfig signingConfigs.debug
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets {
//国内环境采用默认的安全图片
release {
resources.srcDirs = ['src/main/res']
res.srcDirs = ['src/main/res']
}
debug {
resources.srcDirs = ['src/main/res']
res.srcDirs = ['src/main/res']
}
//海外版采用 src/oversea/res 路径下的安全图片
releaseOversea {
resources.srcDirs = ['src/oversea/res']
res.srcDirs = ['src/oversea/res']
}
debugOversea {
resources.srcDirs = ['src/oversea/res']
res.srcDirs = ['src/oversea/res']
}
}
}
tasks.whenTaskAdded { task ->
if (task.name.startsWith('merge') && task.name.endsWith("Resources") && !task.name.contains("Patch")&&!task.name.contains("AndroidTest")) {
println(" ******************* task:" + task.name)
task.doFirst {
//复制oversea 安全图片
File overseaSourceDir = new File(project.getProjectDir().getAbsolutePath() + "/src/oversea/res/drawable/")
if (overseaSourceDir != null) {
println("delete cache file " + overseaSourceDir.name)
}
if (overseaSourceDir.isDirectory()) {
List<File> resFileList = overseaSourceDir.listFiles()
if (!resFileList.isEmpty()) {
for (File f : resFileList) {
if ("yw_1222_114d.jpg".equalsIgnoreCase(f.getName())) {
println("================== start to delete :" + f.getAbsolutePath())
f.delete()
}
}
}
}
File overseaDesDir = new File(project.getProjectDir().getAbsolutePath() + "/configure/oversea/yw_1222_114d.jpg")
if (overseaDesDir.exists()) {
println(overseaDesDir.getAbsoluteFile())
org.apache.commons.io.FileUtils.copyFile(task.project.file(overseaDesDir),
task.project.file(overseaSourceDir.getAbsolutePath() +"/yw_1222_114d.jpg"), true)
} else {
throw new IllegalArgumentException("未找到海外环境的安全图片,请重新检查configure/oversea/目录下,是否存在名称为yw_1222_114d.jpg")
}
//复制china 安全图片
File chinaSourceDir = new File(project.getProjectDir().getAbsolutePath() + "/src/main/res/drawable/")
if (chinaSourceDir != null) {
println("delete cache file " + chinaSourceDir.name)
}
if (chinaSourceDir.isDirectory()) {
List<File> resFileList = chinaSourceDir.listFiles()
if (!resFileList.isEmpty()) {
for (File f : resFileList) {
if ("yw_1222_114d.jpg".equalsIgnoreCase(f.getName())) {
println("================== start to delete :" + f.getAbsolutePath())
f.delete()
}
}
}
}
File chinaDesDir = new File(project.getProjectDir().getAbsolutePath() + "/configure/china/yw_1222_114d.jpg")
if (chinaDesDir.exists()) {
println(chinaDesDir.getAbsoluteFile())
org.apache.commons.io.FileUtils.copyFile(task.project.file(chinaDesDir),
task.project.file(chinaSourceDir.getAbsolutePath() +"/yw_1222_114d.jpg"), true)
} else {
throw new IllegalArgumentException("未找到国内环境的安全图片,请重新检查configure/china/目录下,是否存在名称为yw_1222_114d.jpg")
}
}
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化