-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbuild.gradle
159 lines (147 loc) · 5.86 KB
/
build.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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
apply plugin: 'com.android.application'
android {
// 获取编译环境版本信息 或者类似这种获取方式 rootProject.ext.dependencies["appcompat"]
def versionConfig = rootProject.extensions.getByName("ext").versions
compileSdkVersion versionConfig.compileSdkVersion
buildToolsVersion versionConfig.buildToolsVersion
defaultConfig {
applicationId versionConfig.applicationId
minSdkVersion versionConfig.minSdkVersion
targetSdkVersion versionConfig.targetSdkVersion
versionCode versionConfig.versionCode
versionName versionConfig.versionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
ndk {
// 设置支持的SO库架构 - 如果有so库,需要模拟器运行,可能需要配置
// abiFilters 'armeabi', 'armeabi-v7a', 'arm64-v8a', 'x86_64', 'x86'
abiFilters 'armeabi-v7a', 'arm64-v8a'//, 'armeabi', 'x86_64', 'x86'
}
javaCompileOptions {
annotationProcessorOptions {
arguments = [AROUTER_MODULE_NAME: project.getName()]
}
}
}
signingConfigs {
release {
storeFile file('test.jks')
storePassword "testtest"
keyAlias "test"
keyPassword "testtest"
}
}
buildTypes {
release {
// 开启混淆
minifyEnabled true // 开关开启的话,子模块不管是不是关闭都会被混淆
// Zipalign优化
zipAlignEnabled true
// 移除无用的resource文件
shrinkResources true
// 混淆配置
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
// 签名
signingConfig signingConfigs.release
// 正式包名称
resValue "string", "app_name_s", "@string/app_name_release"
}
//建议关了debug混淆,影响调试
debug {
// 开启混淆
minifyEnabled true // 开关开启的话,子模块不管是不是关闭都会被混淆
// Zipalign优化
zipAlignEnabled true
// 移除无用的resource文件
shrinkResources true
// 混淆配置
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
// 签名
signingConfig signingConfigs.release
// TODO debug包搞个后缀,目前注释掉方便本地调试定位
applicationIdSuffix ".debug"
// 设置不同的名称
resValue "string", "app_name_s", "@string/app_name_debug"
}
}
android.applicationVariants.all { variant ->
variant.outputs.all {
def date = new Date().format("yyyyMMdd", TimeZone.getTimeZone("GMT+08"))
if (variant.buildType.name.equals('debug')) {
outputFileName = "mvvm_${date}_${versionName}.apk"
}
if (variant.buildType.name.equals('release')) {
outputFileName = "mvvm_${versionName}.apk"
}
}
}
// // 配置不同的马甲、渠道信息
// productFlavors {
// dongduoduo {
// manifestPlaceholders = [APP_NAME: "动多多"]
// buildConfigField "String", "BASE_URL", "http://xxxx.xx2.com"
// applicationId "com.hl.dongduoduo"
// }
// // 这些渠道包暂时关闭
// // huawei {
// // manifestPlaceholders = [UMENG_CHANNEL_VALUE: "huawei"]
// // }
// // xiaomi {
// // manifestPlaceholders = [UMENG_CHANNEL_VALUE: "xiaomi"]
// // }
// // baidu {
// // manifestPlaceholders = [UMENG_CHANNEL_VALUE: "baidu"]
// // }
// // tencent {
// // manifestPlaceholders = [UMENG_CHANNEL_VALUE: "tencent"]
// // }
// // _360 {
// // manifestPlaceholders = [UMENG_CHANNEL_VALUE: "360"]
// // }
// }
sourceSets {
main {
if (Boolean.valueOf(rootProject.ext.isModule_Home)) {
manifest.srcFile 'src/main/AndroidManifest.xml'
} else {
manifest.srcFile 'src/debug/AndroidManifest.xml'
}
}
}
dataBinding {
enabled = true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
// modules_home已经用api依赖了base,这里本来不需要再次依赖了的;
// 但是如果我们要共用base的资源,还是需要依赖一下,卧槽!
implementation project(path: ':librarys:lib_common')
// 引入各个模块
if (rootProject.ext.isModule_Home) {
implementation project(path: ':modules:module_home')
}
if (rootProject.ext.isModule_Login) {
implementation project(path: ':modules:module_login')
}
if (rootProject.ext.isModule_Personal) {
implementation project(path: ':modules:module_personal')
}
if (rootProject.ext.isModule_Main) {
implementation project(path: ':modules:module_main')
}
if (rootProject.ext.isModule_ProductDetail) {
implementation project(path: ':modules:module_productdetail')
}
if (rootProject.ext.isModule_ShoppingCar) {
implementation project(path: ':modules:module_shoppingcart')
}
if (rootProject.ext.isModule_Location) {
implementation project(path: ':modules:module_location')
}
// Arouter路由注解
annotationProcessor rootProject.ext.dependencies["arouter_compiler"]
}