1 Star 0 Fork 0

xuyf/AndroidUtilCode

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
settings.gradle 2.47 KB
一键复制 编辑 原始数据 按行查看 历史
布兰柯基 提交于 2020-05-21 14:06 . see 05/21 log
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())
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/xuyfcodecloud/AndroidUtilCode.git
git@gitee.com:xuyfcodecloud/AndroidUtilCode.git
xuyfcodecloud
AndroidUtilCode
AndroidUtilCode
master

搜索帮助

23e8dbc6 1850385 7e0993f3 1850385