-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathsettings.gradle
executable file
·111 lines (99 loc) · 4.15 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
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
/**
* "Build scan" - является общей и централизованной записью сборки которая дает представление о том, что произошло и почему.
* С этим плагином вы можете опубликовать свои записи сборки на https://scans.gradle.com бесплатно.
*
* пример использования: Выполните ./gradlew assembleRelease --scan
* и перейдите по зеленой ссылке в конце сборки, для просмотра результатов сканирования.
*/
plugins {
id "com.gradle.enterprise" version "3.3.4"
}
gradleEnterprise {
buildScan {
termsOfServiceUrl = 'https://gradle.com/terms-of-service'
termsOfServiceAgree = 'yes'
allowUntrustedServer = true
}
}
import groovy.json.JsonSlurper
include ':android-standard-version-plugin'
// used files
def MIRROR_PROPERTIES_FILE = 'mirror.properties'
def ANDROID_STANDARD_PROPERTIES_FILE = 'android-standard/androidStandard.properties'
def COMPONENTS_JSON_FILE = './buildSrc/components.json'
// used properties from above files
def COMMON_COMPONENT_NAME = "surf.commonComponentName"
def MIRROR_COMPONENT_NAME = 'surf.mirrorComponentName'
def SKIP_SAMPLES_BUILD_PROPERTY_NAME = 'skipSamplesBuild'
// initialize reading properties files
def mirrorComponentName = ""
def commonComponentName = ""
if (file(MIRROR_PROPERTIES_FILE).exists()) {
Properties mirrorProperties = new Properties()
mirrorProperties.load(file(MIRROR_PROPERTIES_FILE).newDataInputStream())
mirrorComponentName = mirrorProperties.getProperty(MIRROR_COMPONENT_NAME)
commonComponentName = mirrorProperties.getProperty(COMMON_COMPONENT_NAME)
}
def skipSamples = "false"
if (file(ANDROID_STANDARD_PROPERTIES_FILE).exists()) {
Properties androidStandardProperties = new Properties()
androidStandardProperties.load(file(ANDROID_STANDARD_PROPERTIES_FILE).newDataInputStream())
skipSamples = androidStandardProperties.getProperty(SKIP_SAMPLES_BUILD_PROPERTY_NAME)
}
/**
* Includes components in project
* @param components - [List<Object>] list of components
* @param skipSample - [String] ("true", "false"), is need to skip sample modules
*/
def includeComponents(components) {
components.forEach { component ->
if (component != null && component.libs != null) {
component.libs.forEach { lib ->
def moduleName = ":${lib.name}"
include moduleName
project(moduleName).projectDir = new File("${component.dir}/${lib.dir}")
}
}
}
}
// reading components.json
def componentsJson = file(COMPONENTS_JSON_FILE)
def parsedJson = new JsonSlurper().parseText(componentsJson.text)
// if current component is not a mirror
if (mirrorComponentName == "") {
def result = parsedJson.collect { it.libraries }.flatten() // == flatMap
if (skipSamples == "true") {
includeComponents(result)
} else {
result = result + parsedJson.collect { it.samples }.flatten()
includeComponents(result)
}
} else {
def mirrorComponent = parsedJson.find { it.name == mirrorComponentName }[0]
if (mirrorComponent != null) {
def result = mirrorComponent.libs + mirrorComponent.samples
if (commonComponentName != "") {
def commonComponent = parsedJson.find { it.name == commonComponentName }[0]
if (commonComponent != null) {
includeComponents(result + commonComponent.libraries + commonComponent.samples)
}
} else {
includeComponents(result)
}
}
}
parsedJson.forEach { component ->
component.libs.forEach { lib ->
def moduleName = ":${lib.name}"
include moduleName
project(moduleName).projectDir = new File("${component.dir}/${lib.dir}")
}
if (skipSamples != "true") {
component.samples.forEach { sample ->
def moduleName = ":${sample.name}"
include moduleName
project(moduleName).projectDir = new File("${component.dir}/${sample.dir}")
}
}
}
apply from: 'buildSrc/buildCache.gradle'