-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsettings.gradle
72 lines (59 loc) · 2.37 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
import groovy.json.JsonSlurper
def config = new JsonSlurper().parse(new File(rootProject.projectDir, "settingsConfig.json"))
for (def pro in config.moduleConfig) {
String localPath = pro.localPath
if (localPath.endsWith(":app")) {
if (!config.appConfig.isEmpty()) {
def appName = localPath.substring(":features:".length(), localPath.length() - 4)
if (!config.appConfig.contains(appName)) {
pro.isApply = false
}
}
} else if (localPath.endsWith(":pkg")) {
if (!config.pkgConfig.isEmpty()) {
def pkgName = localPath.substring(":features:".length(), localPath.length() - 4)
if (!config.pkgConfig.contains(pkgName)) {
pro.isApply = false
}
}
}
if (pro.useLocal && pro.isApply) {
include pro.localPath
project(pro.localPath).name = pro.localPath.substring(1).replace(":", "_")
}
}
def ls = System.getProperty("line.separator")
List<String> moduleDeps = []
for (def pro in config.moduleConfig) {
boolean isApply = pro.isApply
boolean useLocal = pro.useLocal
String localPath = pro.localPath
String remotePath = pro.remotePath
String name = localPath.replace(":", "_").replace("-", "_").substring(1)
if (localPath != null) localPath = "\"$localPath\""
if (remotePath != null) remotePath = "\"$remotePath\""
String code = String.format("%-12s%-30s: new DpdInfo($localPath%s, $useLocal),", "", name, remotePath == null ? ", null" : ", $remotePath")
moduleDeps.add(code)
}
def configFile = new File(rootProject.projectDir, '/buildSrc/src/main/groovy/cn/quickits/tools/make/Config.groovy')
def lines = configFile.readLines("utf8")
def configContent = new StringBuilder()
boolean enterNeverFlag = false
for (def line : lines) {
if (enterNeverFlag) {
if (line.contains("/* LocalModule")) {
configContent.append(ls).append(line)
enterNeverFlag = false
}
continue
}
configContent.append(ls).append(line)
if (line.contains("/* LocalModule")) {
configContent.append(ls).append(String.format("%-12s/* Generated by \"settingsConfig.json\" */", ""))
enterNeverFlag = true
for (String dep : moduleDeps) {
configContent.append(ls).append(dep)
}
}
}
configFile.write(configContent.substring(ls.length()).toString())