-
Notifications
You must be signed in to change notification settings - Fork 16
/
settings.gradle.kts
72 lines (66 loc) · 2.22 KB
/
settings.gradle.kts
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
@file:Suppress("UnstableApiUsage")
/*
* 这里每次新建模块都会 include,把它们删掉,因为已经默认 include 了
* */
pluginManagement {
includeBuild("build_logic")
repositories {
gradlePluginPortal()
mavenCentral()
google()
maven("https://jitpack.io")
jcenter() // 部分依赖需要
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
maven("$rootDir/build/maven") // 本地模块缓存文件夹
google()
mavenCentral() // 优先 MavenCentral,一是:github CI 下不了 aliyun 依赖;二是:开 VPN 访问 aliyun 反而变慢了
maven("https://jitpack.io")
jcenter() // 部分依赖需要
// mavenCentral 快照仓库
maven("https://s01.oss.sonatype.org/content/repositories/snapshots/")
maven("https://maven.aliyun.com/repository/public")
maven("https://maven.aliyun.com/repository/google")
mavenLocal() // maven 默认的本地依赖位置:用户名/.m2/repository 中
}
}
rootProject.name = "WanAndroid_Multi"
// 测试使用,排除掉不需要的模块,记得还原!!!
val excludeList = listOf<String>(
)
//对文件夹进行遍历,深度为2
rootDir.walk()
.maxDepth(2)
.asSequence()
.filter {
//过滤掉干扰文件夹
val isDirectory = it.isDirectory
val isSubModule = file("$it/build.gradle").exists() || file("$it/build.gradle.kts").exists()
val isIndependentProject = file("$it/settings.gradle").exists() || file("$it/settings.gradle.kts").exists()
isDirectory && isSubModule && !isIndependentProject
}
.filter {
//对module进行过滤
"(api_.+)|(module_.+)|(lib_.+)".toRegex().matches(it.name)
&& it.name !in excludeList
&& it.parentFile.name !in excludeList // 如果只是写了忽略掉 module_test,那么里面的 api_test 也得一起忽略掉才能彻底忽略
}
.map {
//将file映射到相对路径
val parentFile = it.parentFile
if (parentFile.path == rootDir.path) {
":${it.name}"
} else {
":${parentFile.name}:${it.name}"
}
}
.forEach {
//进行include
include(it)
}
/**
* 每次新建模块会自动添加 include(),请删除掉,因为上面会自动读取
*/