-
Notifications
You must be signed in to change notification settings - Fork 23
/
build.gradle
152 lines (132 loc) · 5.73 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
145
146
147
148
149
150
151
152
// Copyright (c) 2012, J2 Innovations
// Licensed under the Academic Free License version 3.0
//
// History:
// 10 Mar 2016 Richard McElhinney Creation
// 11 May 2017 Christian Tremblay Update (added tags download)
// 09 May 2018 Eric Anderson Updating to latest Niagara Gradle conventions
plugins {
id 'com.tridium.niagara-signing'
id 'com.tridium.niagara' apply false
id 'com.tridium.niagara-module' apply false
id 'com.tridium.niagara-rjs' apply false
}
def getGradleProperty(String propName) {
if (gradle.hasProperty(propName)) {
gradle.getProperty(propName)
} else {
// Get system property, or, failing that, fall back to environment variable
// This allows setting, e.g., -Pniagara_home=blah
System.getProperty(propName) ?: System.getenv(propName)
}
}
ext.niagara_home = getGradleProperty('niagara_home')
ext.niagara_dev_home = getGradleProperty('niagara_dev_home')
ext.niagara_user_home = getGradleProperty('niagara_user_home')
apply from: "${rootProject.ext.niagara_home}/etc/gradle/eclipse.gradle"
apply from: "${rootProject.ext.niagara_home}/etc/gradle/idea.gradle"
gradle.beforeProject { p ->
configure(p) {
def vendorSettings = file("${rootDir}/vendor.gradle")
if (vendorSettings.exists()) {
apply from: vendorSettings
}
apply from: "${rootDir}/gradle/niagara.gradle"
pluginManager.withPlugin("idea") {
idea {
module {
scopes.TEST.plus += [configurations.niagaraModuleTestCompile]
}
}
}
}
}
subprojects { Project p ->
p.pluginManager.withPlugin('com.tridium.niagara-module') {
p.niagaraModule {
certAlias = "ph-code-cert"
}
}
}
tasks.addRule("""
Pattern: [jar[Test]|clean|<any gradle task>]/[path]: Run a Gradle task against a set of modules rooted at path.
""") { String taskName ->
def matcher = taskName =~ /(.*?)(Test)?\/(.*)/
if (matcher) {
def command = matcher.group(1)
def includeTestModules = matcher.group(2) == 'Test'
def path = file("${projectDir}/${matcher.group(3)}").toPath()
assert path.toFile().exists()
def targetProjects = subprojects.findAll { it.projectDir.toPath().startsWith(path) }
// default is build command and build is an alias for Gradle's jar task
if (command.isEmpty() || command == 'build') {
command = 'jar'
}
// Create task for subproject
task(taskName, dependsOn: targetProjects.tasks[command])
if (includeTestModules && command == 'jar') {
tasks[taskName].dependsOn targetProjects.moduleTestJar
}
}
}
///////////////////////////////////////////////////////////////////////////
// Download tags from www.project-haystack.org
///////////////////////////////////////////////////////////////////////////
def srcList = [
'https://project-haystack.org/download/equip-points/ahu',
'https://project-haystack.org/download/equip-points/boiler',
'https://project-haystack.org/download/equip-points/chilledWaterPlant',
'https://project-haystack.org/download/equip-points/chiller',
'https://project-haystack.org/download/equip-points/coolingTower',
'https://project-haystack.org/download/equip-points/elecMeter',
'https://project-haystack.org/download/equip-points/heatExchanger',
'https://project-haystack.org/download/equip-points/hotWaterPlant',
'https://project-haystack.org/download/equip-points/steamPlant',
'https://project-haystack.org/download/equip-points/tank',
'https://project-haystack.org/download/equip-points/vav',
'https://project-haystack.org/download/equip-points/vfd',
'https://project-haystack.org/download/equip-points/zone']
def targetList = [
new File('nhaystack-rt/src/nhaystack/res/equip-points/ahu.txt'),
new File('nhaystack-rt/src/nhaystack/res/equip-points/boiler.txt'),
new File('nhaystack-rt/src/nhaystack/res/equip-points/chilledWaterPlant.txt'),
new File('nhaystack-rt/src/nhaystack/res/equip-points/chiller.txt'),
new File('nhaystack-rt/src/nhaystack/res/equip-points/coolingTower.txt'),
new File('nhaystack-rt/src/nhaystack/res/equip-points/elecMeter.txt'),
new File('nhaystack-rt/src/nhaystack/res/equip-points/heatExchanger.txt'),
new File('nhaystack-rt/src/nhaystack/res/equip-points/hotWaterPlant.txt'),
new File('nhaystack-rt/src/nhaystack/res/equip-points/steamPlant.txt'),
new File('nhaystack-rt/src/nhaystack/res/equip-points/tank.txt'),
new File('nhaystack-rt/src/nhaystack/res/equip-points/vav.txt'),
new File('nhaystack-rt/src/nhaystack/res/equip-points/vfd.txt'),
new File('nhaystack-rt/src/nhaystack/res/equip-points/zone.txt'),
]
task downloadTags(type: FilesDownload) {
group 'nhaystack'
srcs = srcList
targets = targetList
}
def resList = [
'https://project-haystack.org/download/tags.csv',
'https://project-haystack.org/download/tz.txt',
'https://project-haystack.org/download/units.txt']
def resTargetList = [
new File('nhaystack-rt/src/nhaystack/res/tags.csv'),
new File('nhaystack-rt/src/nhaystack/res/tz.txt'),
new File('nhaystack-rt/src/nhaystack/res/units.txt')]
task downloadResources(type: FilesDownload) {
group 'nhaystack'
srcs = resList
targets = resTargetList
}
class FilesDownload extends DefaultTask {
List<String> srcs
List<File> targets
@TaskAction
void download() {
srcs.eachWithIndex { src, index ->
println "Downloading ${src} to ${targets[index].toString()}"
ant.get(src: src, dest: targets[index])
}
}
}