forked from Blankj/AndroidUtilCode
-
Notifications
You must be signed in to change notification settings - Fork 1
/
settings.gradle
73 lines (65 loc) · 2.47 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
import groovy.json.JsonSlurper
/**
* 在 config.json 中 根据 appConfig 和 pkgConfig 来 include 本地模块
*/
def config = new JsonSlurper().parse(file("./config.json"))
for (def pro in config.proConfig) {
String localPath = pro.localPath
if (localPath == ":feature:mock") {
if (config.pkgConfig.isEmpty()) {
pro.isApply = false
}
} else if (localPath.endsWith(":app")) {
def appName = localPath.substring(":feature:".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(":feature:".length(), localPath.length() - 4)
if (!config.pkgConfig.contains(pkgName)) {
pro.isApply = false
}
}
}
if (pro.useLocal && pro.isApply) {
def projectPath = ":" + localPath.substring(1).replace(":", "_")
include projectPath
project(projectPath).projectDir = file(localPath.substring(1).replace(":", "/"))
}
}
def ls = System.getProperty("line.separator")
List<String> proDeps = []
for (def pro in config.proConfig) {
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\""
boolean isApply = pro.isApply
proDeps.add(String.format("%-12s%-27s: new DepConfig(%-5s, %-5s, $localPath%s),",
"", name, isApply, useLocal, remotePath == null ? "" : ", $remotePath"))
}
def configFile = file('./buildSrc/src/main/groovy/Config.groovy')
def lines = configFile.readLines("utf8")
def configContent = new StringBuilder()
boolean enterNeverFlag = false
for (def line : lines) {
if (enterNeverFlag) {
if (line.contains("/*Never")) {
configContent.append(ls).append(line)
enterNeverFlag = false
}
continue
}
configContent.append(ls).append(line)
if (line.contains("/*Never")) {
configContent.append(ls).append(String.format("%-12s/*Generated by \"config.json\"*/", ""))
enterNeverFlag = true
for (String dep : proDeps) {
configContent.append(ls).append(dep)
}
}
}
configFile.write(configContent.substring(ls.length()).toString())