forked from Blankj/AndroidUtilCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuildApp.gradle
More file actions
129 lines (111 loc) · 3.91 KB
/
Copy pathbuildApp.gradle
File metadata and controls
129 lines (111 loc) · 3.91 KB
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
apply {
plugin "com.android.application"
plugin "kotlin-android"
plugin "kotlin-android-extensions"
if (Config.depConfig.plugin_bus.isApply) {
plugin Config.depConfig.plugin_bus.pluginId
}
if (Config.depConfig.plugin_api.isApply) {
plugin Config.depConfig.plugin_api.pluginId
}
}
configSigning()
configApkName()
if (Config.depConfig.plugin_bus.isApply) {
bus {
onlyScanLibRegex = '^([:]|(com\\.blankj)).+$'
}
}
if (Config.depConfig.plugin_api.isApply) {
api {
onlyScanLibRegex = '^([:]|(com\\.blankj)).+$'
}
}
android {
compileSdkVersion Config.compileSdkVersion
defaultConfig {
minSdkVersion Config.minSdkVersion
versionCode Config.versionCode
versionName Config.versionName
applicationId Config.applicationId + suffix
targetSdkVersion Config.targetSdkVersion
multiDexEnabled true
}
buildTypes {
debug {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
applicationIdSuffix ".debug"
resValue "string", "app_name", Config.appName + suffix + ".debug"
}
release {
aaptOptions.cruncherEnabled = false
aaptOptions.useNewCruncher = false
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
resValue "string", "app_name", Config.appName + suffix
}
}
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
debugImplementation Config.depConfig.lib_utildebug.dep
releaseImplementation Config.depConfig.lib_utildebug_no_op.dep
// 根据 Config.pkgConfig 来依赖所有 pkg
for (def entrySet : ConfigUtils.getApplyPkgs().entrySet()) {
api entrySet.value.dep
}
if (Config.depConfig.feature_mock.isApply) {
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"
}
}
}
}