-
-
Notifications
You must be signed in to change notification settings - Fork 40
/
versions.gradle
160 lines (141 loc) · 6.67 KB
/
versions.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
import java.util.regex.Matcher
import java.util.regex.Pattern
/**
* Shared file between builds so that they can all use the same dependencies and
* maven repositories.
**/
ext.deps = [:]
def versions = [:]
versions.android_gradle_plugin = "7.1.0"
versions.android_maven_gradle_plugin = "2.0"
versions.gradle_bintray_plugin = "1.8.0"
versions.booster = "1.4.0"
versions.booster_all = "1.1.1"
versions.support = "28.0.0"
versions.androidx = "1.1.0"
versions.junit = "4.12"
versions.espresso = "3.2.0"
versions.constraint_layout = "1.1.3"
versions.glide = "4.11.0"
versions.rxjava2 = "2.2.0"
versions.rx_android = "2.1.0"
versions.butterknife = "10.1.0"
versions.runner = "1.2.0"
versions.gson = "2.8.5"
def deps = [:]
def support = [:]
support.annotations = "com.android.support:support-annotations:$versions.support"
support.app_compat = "com.android.support:appcompat-v7:$versions.support"
support.recyclerview = "com.android.support:recyclerview-v7:$versions.support"
support.cardview = "com.android.support:cardview-v7:$versions.support"
support.design = "com.android.support:design:$versions.support"
support.v4 = "com.android.support:support-v4:$versions.support"
support.core_utils = "com.android.support:support-core-utils:$versions.support"
deps.support = support
def androidx = [:]
androidx.annotations = "androidx.annotation:annotation:$versions.androidx"
androidx.appcompat = "androidx.appcompat:appcompat:$versions.androidx"
androidx.recyclerview = "androidx.recyclerview:recyclerview:$versions.androidx"
androidx.design = "com.google.android.material:material:$versions.androidx"
androidx.multidex = 'androidx.multidex:multidex:2.0.1'
deps.androidx = androidx
def booster = [:]
booster.gradle_plugin = "com.didiglobal.booster:booster-gradle-plugin:$versions.booster"
booster.task_all = "com.didiglobal.booster:booster-task-all:$versions.booster_all"
booster.transform_all = "com.didiglobal.booster:booster-transform-all:$versions.booster_all"
//采用 cwebp 对资源进行压缩
booster.task_compression_cwebp = "com.didiglobal.booster:booster-task-compression-cwebp:$versions.booster"
//采用 pngquant 对资源进行压缩
booster.task_compression_pngquant = "com.didiglobal.booster:booster-task-compression-pngquant:$versions.booster"
//ap_ 文件压缩
booster.task_processed_res = "com.didiglobal.booster:booster-task-compression-processed-res:$versions.booster"
//去冗余资源
booster.task_resource_deredundancy = "com.didiglobal.booster:booster-task-resource-deredundancy:$versions.booster"
//检查 SNAPSHOT 版本
booster.task_check_snapshot = "com.didiglobal.booster:booster-task-check-snapshot:$versions.booster"
//性能瓶颈检测
booster.transform_lint = "com.didiglobal.booster:booster-transform-lint:$versions.booster"
//多线程优化
booster.transform_thread = "com.didiglobal.booster:booster-transform-thread:$versions.booster"
//资源索引内联
booster.transform_r_inline = "com.didiglobal.booster:booster-transform-r-inline:$versions.booster"
//WebView 预加载
booster.transform_webview = "com.didiglobal.booster:booster-transform-webview:$versions.booster"
//SharedPreferences 优化
booster.transform_shared_preferences = "com.didiglobal.booster:booster-transform-shared-preferences:$versions.booster"
//检查覆盖安装导致的 Resources 和 Assets 未加载的 Bug
booster.transform_res_check = "com.didiglobal.booster:booster-transform-res-check:$versions.booster"
//修复 Toast 在 Android 7.1 上的 Bug
booster.transform_toast = "com.didiglobal.booster:booster-transform-toast:$versions.booster"
//处理系统 Crash
booster.transform_activity_thread = "com.didiglobal.booster:booster-transform-activity-thread:$versions.booster"
deps.booster = booster
def butterknife = [:]
butterknife.runtime = "com.jakewharton:butterknife:$versions.butterknife"
butterknife.compiler = "com.jakewharton:butterknife-compiler:$versions.butterknife"
deps.butterknife = butterknife
def espresso = [:]
espresso.core = "androidx.test.espresso:espresso-core:$versions.espresso"
espresso.contrib = "androidx.test.espresso:espresso-contrib:$versions.espresso"
espresso.intents = "androidx.test.espresso:espresso-intents:$versions.espresso"
deps.espresso = espresso
deps.android_gradle_plugin = "com.android.tools.build:gradle:$versions.android_gradle_plugin"
deps.android_maven_gradle_plugin = "com.github.dcendents:android-maven-gradle-plugin:$versions.android_maven_gradle_plugin"
deps.gradle_bintray_plugin = "com.jfrog.bintray.gradle:gradle-bintray-plugin:$versions.gradle_bintray_plugin"
deps.glide = "com.github.bumptech.glide:glide:$versions.glide"
deps.constraint_layout = "androidx.constraint:constraint-layout:$versions.constraint_layout"
deps.junit = "junit:junit:$versions.junit"
deps.runner = "androidx.test:runner:$versions.runner"
deps.rxjava2 = "io.reactivex.rxjava2:rxjava:$versions.rxjava2"
deps.rx_android = "io.reactivex.rxjava2:rxandroid:$versions.rx_android"
deps.gson = "com.google.code.gson:gson:$versions.gson"
ext.deps = deps
def build_versions = [:]
build_versions.min_sdk = 19
build_versions.target_sdk = 31
build_versions.build_tools = "31.0.0"
ext.build_versions = build_versions
def app_release = [:]
app_release.storeFile = "../keystores/android.keystore"
app_release.storePassword = "xuexiang"
app_release.keyAlias = "android.keystore"
app_release.keyPassword = "xuexiang"
ext.app_release = app_release
/**
* @return 是否为release
*/
def isRelease() {
Gradle gradle = getGradle()
String tskReqStr = gradle.getStartParameter().getTaskRequests().toString()
Pattern pattern
if (tskReqStr.contains("assemble")) {
println tskReqStr
pattern = Pattern.compile("assemble(\\w*)(Release|Debug)")
} else {
pattern = Pattern.compile("generate(\\w*)(Release|Debug)")
}
Matcher matcher = pattern.matcher(tskReqStr)
if (matcher.find()) {
String task = matcher.group(0).toLowerCase()
println("[BuildType] Current task: " + task)
return task.contains("release")
} else {
println "[BuildType] NO MATCH FOUND"
return true
}
}
ext.isRelease = this.&isRelease
//默认添加代码仓库路径
static def addRepos(RepositoryHandler handler) {
handler.mavenLocal()
handler.google { url 'https://maven.aliyun.com/repository/google' }
handler.jcenter { url 'https://maven.aliyun.com/repository/jcenter' }
handler.mavenCentral { url 'https://maven.aliyun.com/repository/central' }
handler.maven { url "https://jitpack.io" }
handler.maven { url 'https://maven.aliyun.com/repository/public' }
handler.maven { url "https://repo1.maven.org/maven2/" }
handler.maven { url 'https://oss.sonatype.org/content/repositories/public' }
//Add the Local repository
handler.maven { url 'LocalRepository' }
}
ext.addRepos = this.&addRepos