forked from Blankj/AndroidUtilCode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.gradle
213 lines (184 loc) · 7.02 KB
/
config.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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
ext {
applicationId = 'com.blankj.androidutilcode'
appName = 'Util'
compileSdkVersion = 27
minSdkVersion = 14
targetSdkVersion = 27
versionCode = 1_021_003
versionName = '1.21.3'// E.g. 1.9.72 => 1,009,072
localDebugPlugin = false
// lib version
kotlin_version = '1.3.0'
support_version = '27.1.1'
leakcanary_version = '1.5.4'
dep = [
// plugin
gradle : "com.android.tools.build:gradle:3.2.1",
kotlin_gradle_plugin : "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version",
android_maven_gradle_plugin: "com.github.dcendents:android-maven-gradle-plugin:2.1",
gradle_bintray_plugin : "com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4",
bus_gradle_plugin : "com.blankj:bus-gradle-plugin:1.3",
// lib
support : [
appcompat_v7: "com.android.support:appcompat-v7:$support_version",
design : "com.android.support:design:$support_version",
],
constraint : "com.android.support.constraint:constraint-layout:1.1.3",
kotlin : "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version",
leakcanary : [
android : "com.squareup.leakcanary:leakcanary-android:$leakcanary_version",
android_no_op: "com.squareup.leakcanary:leakcanary-android-no-op:$leakcanary_version",
],
free_proguard : "com.blankj:free-proguard:0.0.7",
bus : "com.blankj:bus:1.0",
adapt_screen : "com.blankj:adapt-screen:0.0.3",
gson : "com.google.code.gson:gson:2.8.2",
glide : "com.github.bumptech.glide:glide:4.7.1",
retrofit : "com.squareup.retrofit2:retrofit:2.4.0",
javassist : "org.javassist:javassist:3.23.1-GA",
commons_io : "commons-io:commons-io:2.5",
junit : "junit:junit:4.12",
robolectric : "org.robolectric:robolectric:3.1.2",
]
configAndroidDomain = this.&configAndroidDomain
configAppDependencies = this.&configAppDependencies
configUtilCodeDependencies = this.&configUtilCodeDependencies
configSubUtilDependencies = this.&configSubUtilDependencies
}
def configAndroidDomain(Project pro) {
if (pro.plugins.hasPlugin("com.android.application")) {
configAppAndroidDomain(pro)
} else {
configLibAndroidDomain(pro)
}
}
def configAppAndroidDomain(Project pro) {
configField(pro)
configSigning(pro)
configApkName(pro)
pro.android {
compileSdkVersion rootProject.compileSdkVersion
defaultConfig {
applicationId rootProject.applicationId
minSdkVersion rootProject.minSdkVersion
targetSdkVersion rootProject.targetSdkVersion
versionCode rootProject.versionCode
versionName rootProject.versionName
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets {
main.res.srcDirs += 'src/main/res-core'
main.res.srcDirs += 'src/main/res-sub'
}
lintOptions {
abortOnError false
}
}
}
def configField(Project pro) {
pro.android.defaultConfig {
resValue "string", "app_name", rootProject.appName
}
}
def configSigning(Project pro) {
File signPropertiesFile = file('sign/keystore.properties')
if (!signPropertiesFile.exists()) return
pro.android {
Properties properties = new Properties()
properties.load(new FileInputStream(signPropertiesFile))
signingConfigs {
release {
storeFile file(properties['keystore'])
storePassword properties['storePassword']
keyAlias properties['keyAlias']
keyPassword properties['keyPassword']
}
}
buildTypes.release.signingConfig signingConfigs.release
}
}
def configApkName(Project pro) {
pro.android.applicationVariants.all { variant ->
if (variant.buildType.name != "debug") {
variant.getPackageApplication().outputDirectory = new File(project.rootDir.absolutePath + "/apk")
variant.getPackageApplication().outputScope.apkDatas.forEach { apkData ->
apkData.outputFileName = "util_" + variant.versionName.replace(".", "_") + ".apk"
}
}
}
}
def configLibAndroidDomain(Project pro) {
pro.android {
compileSdkVersion rootProject.compileSdkVersion
defaultConfig {
minSdkVersion rootProject.minSdkVersion
versionCode rootProject.versionCode
versionName rootProject.versionName
}
buildTypes {
release {
minifyEnabled false
consumerProguardFiles 'proguard-rules.pro'
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
abortOnError false
}
testOptions.unitTests.all {
testLogging {
events 'passed', 'skipped', 'failed', 'standardOut', 'standardError'
}
}
}
afterEvaluate {
generateReleaseBuildConfig.enabled = false
generateDebugBuildConfig.enabled = false
}
}
def configAppDependencies(Project pro) {
pro.dependencies {
implementation fileTree(include: ['*.jar'], dir: 'app/libs')
implementation project(':utilcode')
implementation project(':subutil')
implementation dep.support.appcompat_v7
implementation dep.support.design
implementation dep.constraint
implementation dep.free_proguard
implementation 'com.r0adkll:slidableactivity:2.0.5'
// LeakCanary
debugImplementation dep.leakcanary.android
releaseImplementation dep.leakcanary.android_no_op
// implementation 'com.blankj:utilcode:1.21.2'
}
}
def configUtilCodeDependencies(Project pro) {
pro.dependencies {
api dep.bus
api dep.kotlin
compileOnly dep.support.appcompat_v7
compileOnly dep.support.design
testImplementation dep.junit
testImplementation dep.robolectric
testImplementation dep.support.appcompat_v7
}
}
def configSubUtilDependencies(Project pro) {
pro.dependencies {
compileOnly dep.support.appcompat_v7
compileOnly dep.support.design
api dep.gson
api(dep.glide) {
exclude group: "com.android.support"
}
api dep.retrofit
testImplementation dep.junit
testImplementation dep.robolectric
}
}
//./gradlew utilcode:bintrayUpload