forked from Blankj/AndroidUtilCode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config_app.gradle
90 lines (79 loc) · 2.69 KB
/
config_app.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
apply {
plugin "com.android.application"
plugin "kotlin-android"
plugin "kotlin-android-extensions"
plugin "com.blankj.bus"
}
configSigning project
configApkName project
android {
compileSdkVersion rootProject.compileSdkVersion
defaultConfig {
minSdkVersion rootProject.minSdkVersion
versionCode rootProject.versionCode
versionName rootProject.versionName
applicationId rootProject.applicationId + suffix
targetSdkVersion rootProject.targetSdkVersion
multiDexEnabled true
resValue "string", "app_name", rootProject.appName + suffix
}
buildTypes {
debug {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
abortOnError false
}
}
dependencies {
// LeakCanary
debugImplementation dep.leakcanary.android
debugImplementation dep.leakcanary.support_fragment
releaseImplementation dep.leakcanary.android_no_op
}
private String getSuffix() {
if (project.name == "launcher-app") return ""
String[] splits = project.name.split("-")
String suffix = ""
if (splits.length == 2) {
suffix = "_" + splits[0]
}
return suffix
}
def configSigning(Project pro) {
File signPropertiesFile = file("${rootDir.path}/sign/keystore.properties")
if (!signPropertiesFile.exists()) return
println "$pro.name config sign start..."
pro.android {
Properties properties = new Properties()
properties.load(new FileInputStream(signPropertiesFile))
signingConfigs {
release {
storeFile new File(signPropertiesFile.getParent(), properties['keystore'])
storePassword properties['storePassword']
keyAlias properties['keyAlias']
keyPassword properties['keyPassword']
}
}
buildTypes.release.signingConfig signingConfigs.release
}
println "$pro.name config sign end..."
}
def configApkName(Project pro) {
pro.android.applicationVariants.all { variant ->
if (variant.buildType.name != "debug") {
variant.getPackageApplication().outputDirectory = new File("${rootDir.path}/apk")
variant.getPackageApplication().outputScope.apkDatas.forEach { apkData ->
apkData.outputFileName = "util" + suffix +
"_" + variant.versionName.replace(".", "_") +
".apk"
}
}
}
}