forked from Blankj/AndroidUtilCode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
buildApp.gradle
111 lines (97 loc) · 3.44 KB
/
buildApp.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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
apply {
plugin "com.android.application"
plugin "kotlin-android"
plugin "kotlin-android-extensions"
if (Config.depConfig.plugin.bus.isApply) {
plugin "com.blankj.bus"
}
if (Config.depConfig.plugin.api.isApply) {
plugin "com.blankj.api"
}
}
configSigning()
configApkName()
android {
compileSdkVersion Config.compileSdkVersion
defaultConfig {
minSdkVersion Config.minSdkVersion
versionCode Config.versionCode
versionName Config.versionName
applicationId Config.applicationId + suffix
targetSdkVersion Config.targetSdkVersion
multiDexEnabled true
resValue "string", "app_name", Config.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'
}
}
packagingOptions {
exclude 'META-INF/*'
}
dexOptions {
preDexLibraries true
javaMaxHeapSize "8g"
maxProcessCount 8
dexInProcess = true
}
}
dependencies {
// LeakCanary
debugImplementation Config.depConfig.leakcanary.android.dep
debugImplementation Config.depConfig.leakcanary.support_fragment.dep
releaseImplementation Config.depConfig.leakcanary.android_no_op.dep
// 根据 Config.pkgConfig 来依赖所有 pkg
for (def entrySet : ConfigUtils.getApplyPkgs().entrySet()) {
api entrySet.value.dep
}
// 如果 Config.pkgConfig 不为空,说明可能导入了部分 pkg,
// 那么可能有些 api 没有实现,需要导入 mock 层的 api
if (!Config.pkgConfig.isEmpty()) {
api Config.depConfig.feature.mock.dep
}
}
def getSuffix() {
if (project.path == ":feature:launcher:app") return ""
return project.path.replace(":", "_").substring(":feature".length(), project.path.length() - ":app".length())
}
def configSigning() {
File signPropertiesFile = file("${rootDir.path}/sign/keystore.properties")
if (!signPropertiesFile.exists()) return
GLog.d("${project.toString()} sign start...")
project.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
}
GLog.d("${project.toString()} sign end...")
}
def configApkName() {
project.android.applicationVariants.all { variant ->
if (variant.buildType.name != "debug") {
def artifact = variant.getPackageApplicationProvider().get()
artifact.outputDirectory = new File("${rootDir.path}/apk")
artifact.outputScope.apkDatas.forEach { apkData ->
apkData.outputFileName = "util" + suffix +
(variant.flavorName == "" ? "" : ("_" + variant.flavorName)) +
"_" + variant.versionName.replace(".", "_") +
"_" + variant.buildType.name +
".apk"
}
}
}
}