1
+ ext {
2
+ androidConfig = [
3
+ applicationId : ' com.blankj.androidutilcode' ,
4
+ appName : ' Util' ,
5
+
6
+ compileSdkVersion : 27 ,
7
+ minSdkVersion : 14 ,
8
+ targetSdkVersion : 27 ,
9
+ versionCode : 1_017_004,
10
+ versionName : ' 1.17.4' // E.g 1.9.72 => 1,009,072
11
+ ]
12
+
13
+ versionConfig = [
14
+ // plugin
15
+ gradle : ' 3.1.3' ,
16
+ kotlin : ' 1.2.30' ,
17
+ // lib
18
+ support : ' 27.1.0' ,
19
+ gson : ' 2.8.2' ,
20
+ glide : ' 4.7.1' ,
21
+ leakcanary : ' 1.5.4' ,
22
+ // test
23
+ junit : ' 4.12' ,
24
+ robolectric : ' 3.1.2'
25
+ ]
26
+
27
+ depConfig = [
28
+ gradle : " com.android.tools.build:gradle:$versionConfig . gradle " ,
29
+ kotlin : " org.jetbrains.kotlin:kotlin-gradle-plugin:$versionConfig . kotlin " ,
30
+
31
+ support : [
32
+ appcompat_v7 : " com.android.support:appcompat-v7:$versionConfig . support " ,
33
+ design : " com.android.support:design:$versionConfig . support " ,
34
+ ],
35
+ leakcanary : [
36
+ android : " com.squareup.leakcanary:leakcanary-android:$versionConfig . leakcanary " ,
37
+ android_no_op : " com.squareup.leakcanary:leakcanary-android-no-op:$versionConfig . leakcanary " ,
38
+ ],
39
+ gson : " com.google.code.gson:gson:$versionConfig . gson " ,
40
+ glide : " com.github.bumptech.glide:glide:$versionConfig . glide " ,
41
+
42
+ junit : " junit:junit:$versionConfig . junit " ,
43
+ robolectric : " org.robolectric:robolectric:$versionConfig . robolectric " ,
44
+ ]
45
+
46
+ configAndroidDomain = this . &configAndroidDomain
47
+ configAppDependencies = this . &configAppDependencies
48
+ configUtilCodeDependencies = this . &configUtilCodeDependencies
49
+ configSubUtilDependencies = this . &configSubUtilDependencies
50
+ }
51
+
52
+ def configAndroidDomain (Project pro ) {
53
+ if (pro. plugins. hasPlugin(" com.android.application" )) {
54
+ configAppAndroidDomain(pro)
55
+ } else {
56
+ configLibAndroidDomain(pro)
57
+ }
58
+ }
59
+
60
+ def configAppAndroidDomain (Project pro ) {
61
+ configField(pro)
62
+ configSigning(pro)
63
+ pro. android {
64
+ compileSdkVersion androidConfig. compileSdkVersion
65
+ defaultConfig {
66
+ applicationId androidConfig. applicationId
67
+ minSdkVersion androidConfig. minSdkVersion
68
+ targetSdkVersion androidConfig. targetSdkVersion
69
+ versionCode androidConfig. versionCode
70
+ versionName androidConfig. versionName
71
+ }
72
+
73
+ buildTypes {
74
+ release {
75
+ minifyEnabled true
76
+ proguardFiles getDefaultProguardFile(' proguard-android.txt' ), ' proguard-rules.pro'
77
+ }
78
+ }
79
+
80
+ sourceSets {
81
+ main. res. srcDirs + = ' src/main/res_core'
82
+ main. res. srcDirs + = ' src/main/res_sub'
83
+ }
84
+
85
+ lintOptions {
86
+ abortOnError false
87
+ }
88
+ }
89
+ }
90
+
91
+ def configField (Project pro ) {
92
+ pro. android. defaultConfig {
93
+ resValue " string" , " app_name" , androidConfig. appName
94
+ }
95
+ }
96
+
97
+ def configSigning (Project pro ) {
98
+ File signPropertiesFile = file(' sign/keystore.properties' )
99
+ if (! signPropertiesFile. exists()) return
100
+ pro. android {
101
+ Properties properties = new Properties ()
102
+ properties. load(new FileInputStream (signPropertiesFile))
103
+ signingConfigs {
104
+ release {
105
+ storeFile file(properties[' keystore' ])
106
+ storePassword properties[' storePassword' ]
107
+ keyAlias properties[' keyAlias' ]
108
+ keyPassword properties[' keyPassword' ]
109
+ }
110
+ }
111
+ buildTypes. release. signingConfig signingConfigs. release
112
+ }
113
+ }
114
+
115
+ def configLibAndroidDomain (Project pro ) {
116
+ pro. android {
117
+ compileSdkVersion androidConfig. compileSdkVersion
118
+ defaultConfig {
119
+ minSdkVersion androidConfig. minSdkVersion
120
+ versionCode androidConfig. versionCode
121
+ versionName androidConfig. versionName
122
+ }
123
+
124
+ buildTypes {
125
+ release {
126
+ minifyEnabled false
127
+ // consumerProguardFiles 'proguard-rules.pro'
128
+ proguardFiles getDefaultProguardFile(' proguard-android.txt' ), ' proguard-rules.pro'
129
+ }
130
+ }
131
+
132
+ lintOptions {
133
+ abortOnError false
134
+ }
135
+
136
+ testOptions. unitTests. all {
137
+ testLogging {
138
+ events ' passed' , ' skipped' , ' failed' , ' standardOut' , ' standardError'
139
+ }
140
+ }
141
+ }
142
+ }
143
+
144
+
145
+ def configAppDependencies (Project pro ) {
146
+ pro. dependencies {
147
+ implementation fileTree(include : [' *.jar' ], dir : ' libs' )
148
+ implementation project(' :utilcode' )
149
+ implementation project(' :subutil' )
150
+
151
+ implementation depConfig. support. appcompat_v7
152
+ implementation depConfig. support. design
153
+ implementation ' com.r0adkll:slidableactivity:2.0.5'
154
+ // LeakCanary
155
+ debugImplementation depConfig. leakcanary. android
156
+ releaseImplementation depConfig. leakcanary. android_no_op
157
+ // implementation 'com.blankj:utilcode:1.17.2'
158
+ }
159
+ }
160
+
161
+ def configUtilCodeDependencies (Project pro ) {
162
+ pro. dependencies {
163
+ compileOnly depConfig. support. appcompat_v7
164
+ compileOnly depConfig. support. design
165
+
166
+ testImplementation depConfig. junit
167
+ testImplementation depConfig. robolectric
168
+ testImplementation depConfig. support. appcompat_v7
169
+ }
170
+ }
171
+
172
+ def configSubUtilDependencies (Project pro ) {
173
+ pro. dependencies {
174
+ compileOnly depConfig. support. appcompat_v7
175
+ compileOnly depConfig. support. design
176
+
177
+ api depConfig. gson
178
+ api(depConfig. glide) {
179
+ exclude group : " com.android.support"
180
+ }
181
+
182
+ testImplementation depConfig. junit
183
+ testImplementation depConfig. robolectric
184
+ }
185
+ }
0 commit comments