forked from liferay/liferay-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
144 lines (108 loc) · 3.52 KB
/
build.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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
buildscript {
if (System.properties["http.proxyHost"] == "squid.lax.liferay.com") {
logger.lifecycle "Using proxy {}:{}.", System.properties["http.proxyHost"], System.properties["http.proxyPort"]
ext {
repositoryUrl = "http://repository.liferay.com/nexus/content/groups/public"
}
}
else {
ext {
repositoryUrl = "https://cdn.lfrs.sl/repository.liferay.com/nexus/content/groups/public"
}
}
repositories {
maven {
url repositoryUrl
}
}
dependencies {
classpath group: "com.liferay", name: "com.liferay.gradle.plugins.node", version: "2.0.0"
classpath group: "com.liferay", name: "com.liferay.gradle.plugins.poshi.runner", version: "1.0.12"
}
}
configure(subprojects.findAll {!it.childProjects}) {
apply plugin: "com.liferay.poshi.runner"
configurations {
poshiRunner {
resolutionStrategy {
force group: "com.google.guava", name: "guava", version: "16.0.1"
force group: "commons-codec", name: "commons-codec", version: "1.10"
}
}
}
poshiRunner {
baseDir = "test/functional"
openCVVersion = "2.4.10-0.10"
poshiProperties << _getTestProperties(project)
poshiPropertiesFile = rootProject.file("${baseDir}/test.properties")
version = "1.0.78"
}
repositories {
maven {
url repositoryUrl
}
}
}
private static Properties _expandProperties(Properties properties) {
boolean propertyExpanded = true
while (propertyExpanded) {
propertyExpanded = false
Set<String> propertyNames = properties.stringPropertyNames()
for (String propertyName : propertyNames) {
String propertyValue = properties.getProperty(propertyName)
Map<String, String> replacements = new HashMap<>()
propertyValue.eachMatch(/\$\{.+?\}/) {
String group ->
String name = group.replace('${', '')
name = name.replace('}', '')
if (propertyNames.contains(name) && (group != properties.getProperty(name))) {
replacements.put group, properties.getProperty(name)
propertyExpanded = true
}
}
for (String group : replacements.keySet()) {
propertyValue = propertyValue.replace(group, replacements.get(group))
}
properties.setProperty propertyName, propertyValue
}
}
properties
}
private static Properties _getCustomProperties(String prefix, File dir) {
Properties properties = new Properties()
for (File propertiesFile in _getCustomPropertiesFiles(prefix, dir)) {
properties << GUtil.loadProperties(propertiesFile)
}
properties
}
private static List<File> _getCustomPropertiesFiles(String prefix, File dir) {
List<String> propertiesFileNames = ["${prefix}.properties"]
if (System.env.HOSTNAME) {
propertiesFileNames << "${prefix}.${System.env.HOSTNAME}.properties"
}
if (System.env.HOST) {
propertiesFileNames << "${prefix}.${System.env.HOST}.properties"
}
if (System.env.COMPUTERNAME) {
propertiesFileNames << "${prefix}.${System.env.COMPUTERNAME}.properties"
}
if (System.env.USER) {
propertiesFileNames << "${prefix}.${System.env.USER}.properties"
}
List<File> propertiesFiles = new ArrayList<>()
for (String propertiesFileName in propertiesFileNames) {
File propertiesFile = new File(dir, propertiesFileName)
if (propertiesFile.exists()) {
propertiesFiles.add(propertiesFile)
}
}
propertiesFiles
}
private static Properties _getTestProperties(Project project) {
Properties properties = new Properties()
properties << _getCustomProperties("test", project.rootProject.projectDir)
if (project != project.rootProject) {
properties << _getCustomProperties("test", new File(project.projectDir, "test/functional"))
}
_expandProperties properties
}