-
Notifications
You must be signed in to change notification settings - Fork 140
/
Copy paththerouter.gradle
118 lines (104 loc) · 4.41 KB
/
therouter.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
def getLocalProperties() {
def properties = new Properties()
try {
File localPropertiesFile
try {
localPropertiesFile = new File(rootDir, 'local.properties');
if (localPropertiesFile == null || !localPropertiesFile.exists()) {
localPropertiesFile = new File("../local.properties")
}
} catch (Exception e) {
localPropertiesFile = new File("../local.properties")
}
println("localPropertiesFile:" + localPropertiesFile.absolutePath)
properties.load(new FileInputStream(localPropertiesFile))
return properties
} catch (Exception e) {
return properties
}
}
def moduleKapt(String compileStr) {
moduleKapt(compileStr, {})
}
def moduleKapt(String compileStr, Closure configureClosure) {
String[] temp = compileStr.split(":")
String group = temp[0]
String artifactid = temp[1]
String version = temp[2]
Set<String> includeModule = new HashSet<>()
rootProject.getAllprojects().each {
if (it != rootProject) includeModule.add(it.name)
}
if (includeModule.contains(artifactid)) {
println(project.name + "源码依赖:project(\":$artifactid\")")
projects.project.dependencies.add(Boolean.valueOf(USE_KAPT) ? "kapt" : "ksp", project(':' + artifactid), configureClosure)
// projects.project.configurations { compile.exclude group: group, module: artifactid }
} else {
println(project.name + "依赖:$group:$artifactid:$version")
projects.project.dependencies.add(Boolean.valueOf(USE_KAPT) ? "kapt" : "ksp", "$group:$artifactid:$version", configureClosure)
}
}
def moduleApi(String compileStr) {
moduleApi(compileStr, {})
}
def moduleApi(String compileStr, Closure configureClosure) {
String[] temp = compileStr.split(":")
String group = temp[0]
String artifactid = temp[1]
String version = temp[2]
Set<String> includeModule = new HashSet<>()
rootProject.getAllprojects().each {
if (it != rootProject) includeModule.add(it.name)
}
if (includeModule.contains(artifactid)) {
println(project.name + "源码依赖:project(\":$artifactid\")")
projects.project.dependencies.add("api", project(':' + artifactid), configureClosure)
// projects.project.configurations { compile.exclude group: group, module: artifactid }
} else {
println(project.name + "依赖:$group:$artifactid:$version")
projects.project.dependencies.add("api", "$group:$artifactid:$version", configureClosure)
}
}
def moduleImplementation(String compileStr) {
moduleImplementation(compileStr, {})
}
def moduleImplementation(String compileStr, Closure configureClosure) {
String[] temp = compileStr.split(":")
String group = temp[0]
String artifactid = temp[1]
String version = temp[2]
Set<String> includeModule = new HashSet<>()
rootProject.getAllprojects().each {
if (it != rootProject) includeModule.add(it.name)
}
if (includeModule.contains(artifactid)) {
println(project.name + "源码依赖:project(\":$artifactid\")")
projects.project.dependencies.add("implementation", project(':' + artifactid), configureClosure)
// projects.project.configurations { compile.exclude group: group, module: artifactid }
} else {
println(project.name + "依赖:$group:$artifactid:$version")
projects.project.dependencies.add("implementation", "$group:$artifactid:$version", configureClosure)
}
}
ext {
moduleKapt = this.&moduleKapt
moduleApi = this.&moduleApi
moduleImplementation = this.&moduleImplementation
getLocalProperties = this.&getLocalProperties
def wrapperDir = file("${rootProject.projectDir}/gradle/wrapper")
def targetWrapperFile = new File(wrapperDir, "gradle-wrapper.properties")
FileWriter stream = new FileWriter(targetWrapperFile)
String text = "#Tue Jun 22 08:02:06 CST 2021\n" +
"distributionBase=GRADLE_USER_HOME\n" +
"distributionPath=wrapper/dists\n" +
"zipStoreBase=GRADLE_USER_HOME\n" +
"zipStorePath=wrapper/dists\n"
if (Boolean.valueOf(gradle8)) {
text += "distributionUrl=https\\://services.gradle.org/distributions/gradle-8.0.2-all.zip\n"
} else {
text += "distributionUrl=https\\://services.gradle.org/distributions/gradle-7.6.1-all.zip\n"
}
stream.write(text)
stream.flush()
stream.close()
}