-
Notifications
You must be signed in to change notification settings - Fork 3
/
settings.gradle
81 lines (66 loc) · 2.18 KB
/
settings.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
import java.util.regex.Matcher
import java.util.regex.Pattern
apply from: './commonGradle/gradle_config_optimize.gradle'
dependencyResolutionManagement {
repositories {
maven {
name = "GitHubPackages"
url 'https://maven.pkg.github.com/Heart-Beats/BaseProject'
credentials {
username = 'Heart-Beats'
password = GITHUB_PACKAGES_READ_TOKEN
}
}
}
versionCatalogs {
// 默认创建的 libs 进行配置
libs {
from("com.hl:catalog:1.0.3")
version("androidGradlePlugin", "8.0.1")
version("kotlin", "1.8.20")
version("minSdk", "26")
}
}
}
rootProject.name = "BaseProject"
include ':app', ':benchmark'
def includeBuildProjects = ['libs/project', 'libs/uikit']
// 是否使用远程依赖库方式
if (!isUseRemoteDependencies.toBoolean()) {
includeBuildProjects.forEach {
println "开始添加构建 -------------> $it"
includeBuild(it)
}
}
//setting.gradle 加载和评估配置阶段完成
gradle.settingsEvaluated {
println '设置加载完毕'
}
//项目加载完成
gradle.projectsLoaded {
println "${it} ---------> projectsLoaded"
gradle.rootProject.buildscript {
println '开始执行初始化配置脚本'
}
}
def getCurrentFlavor(Project project) {
Gradle gradle = project.getGradle()
String tskReqStr = gradle.getStartParameter().getTaskRequests().toString()
Pattern pattern = Pattern.compile("(assemble|generate|bundle)(.*?)(Release|Debug)")
Matcher matcher = pattern.matcher(tskReqStr)
String channel = ""
if (matcher.find()) {
channel = matcher.group(2).toLowerCase()
}
return channel
}
gradle.addProjectEvaluationListener(new ProjectEvaluationListener() {
void beforeEvaluate(Project project) {
println "${project} -------------> beforeEvaluate"
println "currentFlavor -------------> ${getCurrentFlavor(project)}"
}
void afterEvaluate(Project project, ProjectState state) {
println "${project} -------------> afterEvaluate"
println "currentFlavor -------------> ${getCurrentFlavor(project)}"
}
})