forked from didi/DoKit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
238 lines (195 loc) · 6.91 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
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
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
apply from: "config.gradle"
def runType = rootProject.ext.publish_config["run_type"]
def dokitPluginVersion = rootProject.ext.publish_config["version"]
def kotlinVersion
if (needKotlinV14()) {
kotlinVersion = rootProject.ext.android["kotlin_version_v14"]
} else {
kotlinVersion = rootProject.ext.android["kotlin_version_v13"]
}
def gradlePluginVersion = rootProject.ext.android["agp_module_verson"]
repositories {
google()
mavenCentral()
jcenter()
maven {
url "https://oss.sonatype.org/content/groups/public"
}
println("[dokit build] add buildscript private repositories")
println("[dokit build] usePrivateEnv=" + usePrivateEnv() +",privateRepository="+ privateRepository())
println("[dokit build] useLocalRepository="+useLocalRepository()+",localRepository="+localRepository() )
if (usePrivateEnv()){
maven {
url privateRepository()
}
}
if (useLocalRepository()){
maven {
url uri(localRepository())
}
}
}
dependencies {
classpath "com.android.tools.build:gradle:$gradlePluginVersion"
// MavenCentral
classpath "org.jetbrains.dokka:dokka-gradle-plugin:1.4.30"
if (runType == 1) {
classpath "io.github.didi.dokit:dokitx-plugin:$dokitPluginVersion"
}
// classpath "com.didiglobal.booster:booster-task-compression-pngquant:${rootProject.ext.android["booster_version"]}"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
// classpath "com.didiglobal.booster:booster-gradle-plugin:3.3.1"
// classpath "com.didiglobal.booster:booster-task-analyser:3.3.1"
}
}
apply from: "./config.gradle"
allprojects {
def isRootProject = "Dokit-Android".equals(project.name)
repositories {
google()
mavenCentral()
jcenter()
maven {
url "https://oss.sonatype.org/content/groups/public"
}
println("[dokit build] add allprojects repositories config project=" + project.name)
println("[dokit build] usePrivateEnv=" + usePrivateEnv() + ",privateRepository=" + privateRepository())
println("[dokit build] useLocalRepository=" + useLocalRepository() + ",localRepository=" + localRepository())
if (usePrivateEnv()) {
maven {
url privateRepository()
}
}
if (useLocalRepository()){
maven {
url uri(localRepository())
}
}
}
}
task clean(type: Delete) {
doLast {
delete rootProject.buildDir
}
}
/**
* 删除指定目录下的文件
*/
task deleteSource(type: Delete) {
doFirst {
println("path===>${project.rootDir}")
println("===delete Plugin Source start===")
}
followSymlinks = true
delete "${project.rootDir}/dokit-plugin/src/main/kotlin"
doLast {
println("===delete Plugin Source end===")
}
}
/**
* 将buildSrc中的代码同步到doraemonkit-plugin中
*/
task copyPluginSource(type: Copy, dependsOn: deleteSource) {
doFirst {
println("===copy Plugin Source start===")
}
from "${project.rootDir}/buildSrc/src/main/kotlin"
into "${project.rootDir}/dokit-plugin/src/main/kotlin"
include('**/*')
doLast {
println("===copy Plugin Source end===")
}
}
/**
* 打包上传配置检查
*/
task checkUploadConfig4Maven() {
doLast {
if (rootProject.ext.publish_config["archives_type"] != 2) {
throw new RuntimeException("执行当前打包上传任务必须修改config.gradle配置中的archives_type = 2。")
}
//仓库检查
def repositories = new ArrayList<String>()
rootProject.repositories.forEach {
if (it instanceof MavenArtifactRepository) {
repositories.add((it as MavenArtifactRepository).url.toString())
}
}
//相关模块检查
def modules = new ArrayList<String>()
rootProject.allprojects.forEach {
modules.add(it.name)
}
// if (!modules.contains("dokit-rpc")) {
// throw new RuntimeException("未找到dokit-rpc module。。。")
// }
//
// if (!modules.contains("dokit-rpc-mc")) {
// throw new RuntimeException("未找到dokit-rpc-mc module。。。")
// }
if (!modules.contains("dokit-plugin")) {
throw new RuntimeException("未找到dokit-plugin module。。。")
}
}
}
task checkUploadConfig4Local() {
doLast {
//配置检查
if (rootProject.ext.publish_config["archives_type"] != 0) {
throw new RuntimeException("执行当前打包上传任务必须修改config.gradle配置中的archives_type = 0。")
}
//仓库检查
def repositories = new ArrayList<String>()
rootProject.repositories.forEach {
if (it instanceof MavenArtifactRepository) {
repositories.add((it as MavenArtifactRepository).url.toString())
}
}
//相关模块检查
def modules = new ArrayList<String>()
rootProject.allprojects.forEach {
modules.add(it.name)
}
// if (!modules.contains("dokit-rpc")) {
// throw new RuntimeException("未找到dokit-rpc module。。。")
// }
//
// if (!modules.contains("dokit-rpc-mc")) {
// throw new RuntimeException("未找到dokit-rpc-mc module。。。")
// }
if (!modules.contains("dokit-plugin")) {
throw new RuntimeException("未找到dokit-plugin module。。。")
}
}
}
task checkUploadConfig4Didi() {
doLast {
if (rootProject.ext.publish_config["archives_type"] != 1) {
throw new RuntimeException("执行当前打包上传任务必须修改config.gradle配置中的archives_type = 1。")
}
//仓库检查
def repositories = new ArrayList<String>()
rootProject.repositories.forEach {
if (it instanceof MavenArtifactRepository) {
repositories.add((it as MavenArtifactRepository).url.toString())
}
}
//相关模块检查
def modules = new ArrayList<String>()
rootProject.allprojects.forEach {
modules.add(it.name)
}
// if (!modules.contains("dokit-rpc")) {
// throw new RuntimeException("未找到dokit-rpc module。。。")
// }
//
// if (!modules.contains("dokit-rpc-mc")) {
// throw new RuntimeException("未找到dokit-rpc-mc module。。。")
// }
if (!modules.contains("dokit-plugin")) {
throw new RuntimeException("未找到dokit-plugin module。。。")
}
}
}