-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle
322 lines (280 loc) · 9.01 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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
plugins {
id "com.jfrog.bintray" version "1.8.4"
id "com.github.ben-manes.versions" version "0.22.0"
}
apply plugin: 'maven-publish'
apply plugin: 'com.jfrog.bintray'
def baseJvmArgs = [
"--illegal-access=warn",
"--add-opens=java.base/sun.nio.ch=ALL-UNNAMED"
]
project.ext.set("baseJvmArgs", baseJvmArgs)
allprojects {
ext {
fulcrumVersion = "0.34.0"
gsonVersion = "2.8.5"
gsonExtrasVersion = "0.2.1"
hamcrestVersion = "2.1"
httpasyncclientVersion = "4.1.4"
httpclientVersion = "4.5.9"
indigoVersion = "1.24.0"
junitVersion = "4.12"
kafkaClientsVersion = "2.3.0"
log4jVersion = "1.2.17"
log4jextrasVersion = "0.2.0"
mockitoVersion = "3.0.0"
slf4jVersion = "1.7.25"
socketxVersion = "0.8.0"
wiremockVersion = "2.24.1"
yconfVersion = "0.19.0"
}
apply plugin: 'java'
apply plugin: 'jacoco'
apply plugin: 'maven-publish'
apply plugin: 'com.jfrog.bintray'
sourceCompatibility = 1.8
targetCompatibility = 1.8
repositories {
jcenter()
maven {
url 'https://oss.sonatype.org/content/repositories/snapshots'
}
}
jacoco {
toolVersion = '0.8.4'
}
jacocoTestReport {
additionalSourceDirs.from = files(sourceSets.main.allSource.srcDirs)
sourceDirectories.from = files(sourceSets.main.allSource.srcDirs)
classDirectories.from = files(sourceSets.main.output)
reports {
html.enabled = true
xml.enabled = true
csv.enabled = false
}
}
// invoke this task when ready to publish to Bintray
bintrayUpload {
dependsOn ':bintrayCredentialsCheck'
}
dependencies {
testCompile "com.obsidiandynamics.indigo:indigo-assurance:${indigoVersion}"
testCompile "com.obsidiandynamics.fulcrum:fulcrum-assert:${fulcrumVersion}"
testCompile "com.obsidiandynamics.fulcrum:fulcrum-junit:${fulcrumVersion}"
testCompile "com.obsidiandynamics.fulcrum:fulcrum-threads:${fulcrumVersion}"
testCompile "junit:junit:${junitVersion}"
testCompile "org.mockito:mockito-core:${mockitoVersion}"
testCompile "org.hamcrest:hamcrest-library:${hamcrestVersion}"
testRuntime "org.slf4j:slf4j-log4j12:${slf4jVersion}"
testRuntime "log4j:log4j:${log4jVersion}"
}
test {
jvmArgs += baseJvmArgs
}
}
subprojects {
dependencies {
compile project(':')
testCompile project(':').sourceSets.test.output
}
}
task jacocoMerge(type: JacocoMerge) {
mustRunAfter = allprojects.test
executionData = files(allprojects.jacocoTestReport.executionData)
doFirst {
executionData = files(files(allprojects.jacocoTestReport.executionData).findAll { it.exists() })
}
}
task jacocoRootReport(type: JacocoReport) {
dependsOn jacocoMerge
mustRunAfter = allprojects.test
additionalSourceDirs.from = files(allprojects.sourceSets.main.allSource.srcDirs)
sourceDirectories.from = files(allprojects.sourceSets.main.allSource.srcDirs)
classDirectories.from = files(allprojects.sourceSets.main.output)
executionData jacocoMerge.destinationFile
reports {
html.enabled = true
xml.enabled = false
csv.enabled = false
}
onlyIf = {
true
}
}
def versionFile(extension) {
return new File(sourceSets.main.resources.srcDirs[0].path + '/' + project.name + extension)
}
def getVersion(extension) {
def versionFile = versionFile extension
if (! versionFile.exists()) return '0'
def reader = new BufferedReader(new FileReader(versionFile))
def version = reader.readLine().trim()
reader.close()
return version
}
def setVersion(extension, version) {
def versionFile = versionFile extension
def writer = new BufferedWriter(new FileWriter(versionFile))
writer.write(String.valueOf(version))
writer.close()
}
def packageVersion = getVersion '.version'
def packageBuild = getVersion '.build'
task getBuild() {
doLast {
println "At ${getVersion('.version')}_${getVersion('.build')}"
}
}
task setBuild() {
doLast {
def timestamp = new java.text.SimpleDateFormat('yyMMddHHmm').format(new Date())
setVersion('.build', timestamp)
}
}
def packageName = 'flywheel-core'
group = 'au.com.williamhill.flywheel'
version = packageVersion
def envUser = 'BINTRAY_USER'
def envKey = 'BINTRAY_KEY'
task bintrayCredentialsCheck {
doLast {
if (System.getenv(envUser) == null) {
throw new GradleException("No Bintray username specified; set with 'export ${envUser}=<username>'")
}
if (System.getenv(envKey) == null) {
throw new GradleException("No Bintray key specified; set with 'export ${envKey}=<key>'")
}
}
}
repositories {
jcenter()
}
dependencies {
compile "org.slf4j:slf4j-api:{slf4jVersion}"
compile "com.obsidiandynamics.fulcrum:fulcrum-combinations:${fulcrumVersion}"
compile "com.obsidiandynamics.indigo:indigo-core:${indigoVersion}"
compile "com.obsidiandynamics.yconf:yconf-core:${yconfVersion}"
compile "com.obsidiandynamics.yconf:yconf-juel:${yconfVersion}"
compile "com.obsidiandynamics.yconf:yconf-snakeyaml:${yconfVersion}"
compile "com.obsidiandynamics.socketx:socketx-core:${socketxVersion}"
compile "com.obsidiandynamics.socketx:socketx-undertow:${socketxVersion}"
compile "com.google.code.gson:gson:${gsonVersion}"
compile "org.danilopianini:gson-extras:${gsonExtrasVersion}"
testCompile "com.obsidiandynamics.fulcrum:fulcrum-shell:${fulcrumVersion}"
testCompile "org.apache.httpcomponents:httpclient:${httpclientVersion}"
}
def packageDesc = 'A simple, fast, WebSocket-based IoT message broker'
def repoName = 'flywheel'
bintray {
user = System.getenv(envUser)
key = System.getenv(envKey)
publications = ['mavenJava']
pkg {
repo = "${repoName}"
name = packageName
userOrg = 'william-hill-community'
desc = packageDesc
websiteUrl = "https://github.com/william-hill-community/${repoName}"
licenses = ['BSD New']
vcsUrl = "https://github.com/william-hill-community/${repoName}"
issueTrackerUrl = "https://github.com/william-hill-community/${repoName}/issues"
publicDownloadNumbers = true
githubRepo = "william-hill-community/${repoName}"
override = true
publish = false
version {
name = project(':').version
desc = packageDesc
released = new Date()
vcsTag = project(':').version
}
}
}
// invoke this task when ready to publish to Bintray
bintrayUpload {
dependsOn bintrayCredentialsCheck
}
processResources {
dependsOn setBuild
}
jar {
baseName packageName
finalizedBy jacocoRootReport
}
task javadocJar(type: Jar, dependsOn: javadoc) {
baseName packageName
classifier = 'javadoc'
from "$buildDir/docs/javadoc"
}
task sourcesJar(type: Jar) {
baseName packageName
from sourceSets.main.allSource
classifier = 'sources'
}
artifacts {
archives jar
archives javadocJar
archives sourcesJar
}
publishing {
publications {
mavenJava(MavenPublication) {
groupId group
artifactId packageName
version packageVersion
from components.java
artifact sourcesJar
artifact javadocJar
}
}
repositories {
maven {
url "${project(':').projectDir}/../repo"
}
}
}
task testJar(type: Jar) {
dependsOn configurations.compile
dependsOn configurations.runtime
dependsOn configurations.testCompile
dependsOn configurations.testRuntime
dependsOn jar
from sourceSets.main.output
from sourceSets.test.output
from { // bundle all dependencies
configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }
configurations.runtime.collect { it.isDirectory() ? it : zipTree(it) }
configurations.testCompile.collect { it.isDirectory() ? it : zipTree(it) }
configurations.testRuntime.collect { it.isDirectory() ? it : zipTree(it) }
}
baseName packageName + '-test'
}
def perfJvmArgs = '-server -XX:-MaxFDLimit -XX:+TieredCompilation -XX:+UseNUMA -XX:+UseCondCardMark -XX:-UseBiasedLocking -Xms1G -Xmx2G -Xss1M -XX:+UseParallelGC'
task doubleRigBench(type: JavaExec) {
classpath = sourceSets.main.runtimeClasspath + sourceSets.test.runtimeClasspath
jvmArgs = Arrays.asList perfJvmArgs.split(' ')
main = 'au.com.williamhill.flywheel.rig.DoubleRigBenchmark'
}
task tripleRigBench(type: JavaExec) {
classpath = sourceSets.main.runtimeClasspath + sourceSets.test.runtimeClasspath
jvmArgs = Arrays.asList perfJvmArgs.split(' ')
main = 'au.com.williamhill.flywheel.rig.TripleRigBenchmark'
}
task edgeRigBench(type: JavaExec) {
systemProperties = System.properties
classpath = sourceSets.main.runtimeClasspath + sourceSets.test.runtimeClasspath
jvmArgs = Arrays.asList perfJvmArgs.split(' ')
main = 'au.com.williamhill.flywheel.rig.EdgeRigBenchmark'
}
task remoteRigBench(type: JavaExec) {
systemProperties = System.properties
classpath = sourceSets.main.runtimeClasspath + sourceSets.test.runtimeClasspath
jvmArgs = Arrays.asList perfJvmArgs.split(' ')
main = 'au.com.williamhill.flywheel.rig.RemoteRigBenchmark'
}
task injectorRigBench(type: JavaExec) {
systemProperties = System.properties
classpath = sourceSets.main.runtimeClasspath + sourceSets.test.runtimeClasspath
jvmArgs = Arrays.asList perfJvmArgs.split(' ')
main = 'au.com.williamhill.flywheel.rig.InjectorRigBenchmark'
}