forked from Blankj/AndroidUtilCode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.gradle
174 lines (151 loc) · 5.82 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
ext {
applicationId = 'com.blankj.androidutilcode'
appName = 'Util'
compileSdkVersion = 27
minSdkVersion = 14
targetSdkVersion = 27
versionCode = 1_022_000
versionName = '1.22.0'// 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",
multidex : "com.android.support:multidex:1.0.2",
],
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
}
def configAndroidDomain(Project pro) {
configCommon(pro)
if (pro.plugins.hasPlugin("com.android.application")) {
configAppAndroidDomain(pro)
} else {
configLibAndroidDomain(pro)
}
}
def configCommon(Project pro) {
pro.android {
compileSdkVersion rootProject.compileSdkVersion
defaultConfig {
minSdkVersion rootProject.minSdkVersion
versionCode rootProject.versionCode
versionName rootProject.versionName
}
lintOptions {
abortOnError false
}
testOptions.unitTests.all {
testLogging {
events 'passed', 'skipped', 'failed', 'standardOut', 'standardError'
}
}
}
}
def configAppAndroidDomain(Project pro) {
configSigning(pro)
configApkName(pro)
String suffix = getSuffix(pro)
pro.android {
defaultConfig {
applicationId rootProject.applicationId + suffix
targetSdkVersion rootProject.targetSdkVersion
multiDexEnabled true
resValue "string", "app_name", rootProject.appName + suffix
}
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'
}
}
pro.dependencies {
// LeakCanary
debugImplementation dep.leakcanary.android
releaseImplementation dep.leakcanary.android_no_op
}
}
private static String getSuffix(Project pro) {
String[] splits = pro.name.split("-")
String suffix = ""
if (splits.length == 2) {
suffix = "." + splits[0]
}
return suffix
}
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 {
buildTypes {
release {
minifyEnabled false
consumerProguardFiles 'proguard-rules.pro'
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
afterEvaluate {
generateReleaseBuildConfig.enabled = false
generateDebugBuildConfig.enabled = false
}
}
//./gradlew clean utilcode-lib:bintrayUpload