-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathconfig.gradle
78 lines (70 loc) · 2.67 KB
/
config.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
import groovy.json.JsonSlurper
ext {
android = [
compileSdkVersion : 28,
buildToolsVersion : "28.0.3",
minSdkVersion : 22,
targetSdkVersion : 28,
versionCode : 1,
versionName : "1.0",
supportV4Version : "28.0.0",
appcompatV7Version: "28.0.0",
arouterVersion : "1.5.0"
]
//获取当前分支
getCurrentBranch = {
String[] temp = file("$rootDir/.git/HEAD").text.split("heads/")
return temp[1]
}
//增加enjoy属性
String rootDir = project.rootProject.rootDir
File enjoyJson = new File(rootDir + "/enjoyManager/enjoy.json")
//增加enjoy属性
chooseMap = new HashMap<>()
if (enjoyJson.exists()) {
def jsonArray = new JsonSlurper().parse(enjoyJson)
jsonArray.each {
def branch = it["branch"]
def moduleInfo = it["modules"]
def currentBranch = getCurrentBranch()
if ("${currentBranch}".contains("$branch")) {
moduleInfo.each {
chooseMap.put(it.name, it.choose)
}
}
}
}
//增加root local属性文件
localProperties = new Properties()
if (project.rootProject.file('local.properties').exists()) {
InputStream localStream = project.rootProject.file('local.properties').newDataInputStream()
localProperties.load(localStream)
}
//增加root version属性文件
versionProperties = new Properties()
InputStream inputStream = project.rootProject.file('version.properties').newDataInputStream()
versionProperties.load(inputStream)
//增加module目录下的version.properties属性文件
moduleVersion = new Properties()
if (project.file('version.properties').exists()) {
InputStream moduleVersionStream = project.file('version.properties').newDataInputStream()
moduleVersion.load(moduleVersionStream)
}
//是否源码构建
isSourceBuild = { projectName ->
if (!Boolean.valueOf(localProperties.getProperty("aarBuild"))) {
if (!project.hasProperty("aarBuild") || project.aarBuild == "unspecified" || !Boolean.valueOf(project.aarBuild)) {
return true
}
}
return Boolean.valueOf(project.aarBuild) ? !Boolean.valueOf(project.aarBuild) : !chooseMap.get(projectName, false)
}
//依赖aar的版本号
loadAARVersion = { projectName ->
if (!localProperties.getProperty(projectName)) {
return versionProperties.getProperty(projectName)
} else {
return localProperties.getProperty(projectName)
}
}
}