/
build.gradle
467 lines (390 loc) · 13.8 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
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
jcenter()
}
dependencies {
classpath 'com.gradle:build-scan-plugin:1.8'
classpath "com.github.jengelman.gradle.plugins:shadow:2.0.1"
classpath 'com.netflix.nebula:gradle-ospackage-plugin:4.4.+'
classpath "gradle.plugin.nl.javadude.gradle.plugins:license-gradle-plugin:0.14.0"
classpath "gradle.plugin.com.github.spotbugs:gradlePlugin:1.6.0"
}
}
def gitVersion() {
def versionText = [
"sh", "-c",
"cd ${project.rootDir} ; git describe --always --tag"].execute().in.text.trim()
versionText
}
apply plugin: 'com.gradle.build-scan'
allprojects {
apply plugin: 'java'
apply plugin: "com.github.hierynomus.license"
repositories {
mavenCentral()
jcenter()
}
license {
header rootProject.file('LICENSE-HEADER.template')
strictCheck true
ext.year = '2016-2017'
ext.name = 'Nautilus Technologies, Inc.'
excludes(["**/*.json", "**/*.jks"])
}
}
subprojects {
apply plugin: 'jacoco'
apply plugin: 'scala'
apply plugin: 'eclipse'
apply plugin: 'com.github.spotbugs'
apply plugin: 'checkstyle'
apply plugin: 'maven'
apply plugin: 'maven-publish'
group = 'io.github.retz'
// Note: You can't create RPM with hyphen included in version name
version = '0.5.0-SNAPSHOT'
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
ext.retzMavenRepo = project.version.contains("-SNAPSHOT") ? "s3://retz-maven/snapshots" : "s3://retz-maven/releases"
dependencies {
compile 'org.slf4j:slf4j-api:1.7.25'
testCompile 'junit:junit:4.12'
testCompile 'org.hamcrest:hamcrest-library:1.3'
testCompile 'org.scalacheck:scalacheck_2.12:1.13.+'
testCompile 'org.scalatest:scalatest_2.12:3.0.+'
testCompile 'org.scala-lang:scala-library:2.12.+'
}
jar {
def versionText = gitVersion()
manifest {
attributes 'Git-Version': versionText
attributes 'Artifact-Id': "${project.name}-${project.version}"
}
}
task sourcesJar(type: Jar) {
classifier 'sources'
from project.sourceSets.main.allJava
}
artifacts {
archives project.tasks.sourcesJar
}
eclipse {
project.buildCommand 'org.eclipse.jdt.core.javabuilder'
}
test {
useJUnit()
testLogging { // Show that tests are run in the command-line output
events 'failed', 'passed'
}
}
jacocoTestReport {
reports {
html.enabled = true
xml.enabled = true
csv.enabled = false
html.destination file("${buildDir}/reports/jacoco")
}
}
// To generate an HTML report instead of XML
tasks.withType(com.github.spotbugs.SpotBugsTask) {
reports {
xml.enabled = false
html.enabled = true
}
}
checkstyle {
toolVersion = "8.1"
configFile = rootProject.file('checkstyle.xml')
ignoreFailures = true
}
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
artifact sourcesJar
}
}
repositories {
maven {
url retzMavenRepo
credentials(AwsCredentials) {
accessKey System.getenv('AWS_ACCESS_KEY_ID')
secretKey System.getenv('AWS_SECRET_ACCESS_KEY')
}
}
}
}
task copyReport(type: Copy) {
from "build/test-results"
into "$rootDir/build/all-test-report"
}
test.finalizedBy(copyReport)
}
project(':retz-common') {
dependencies {
compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.+'
compile group: 'com.fasterxml.jackson.datatype', name: 'jackson-datatype-jdk8', version: '2.+'
compile 'org.slf4j:slf4j-api:1.7.25'
testCompile 'org.slf4j:slf4j-simple:1.7.25'
}
}
def makePropertyFile(basedir, testType, name, version) {
// A kludge workaround for clean build which don't have build/resources/main
// where property file creation fails
def subdir = new File(basedir, "/resources/${testType}")
subdir.mkdirs();
def serverName = "${name}-${version} (${gitVersion()})"
// Bundle correctly corresponding file name; See RetzScheduler.setJarUri
def prop = new Properties()
prop.setProperty("servername", serverName)
def propFile = new File(subdir, "retz-server.properties")
propFile.createNewFile()
propFile.withOutputStream { out ->
prop.store(out, null)
}
}
def makeClientPropertyFile(basedir, testType, name, version) {
// A kludge workaround for clean build which don't have build/resources/main
// where property file creation fails
def subdir = new File(basedir, "/resources/${testType}")
subdir.mkdirs();
def fullVersion = "${name}-${version} (${gitVersion()})"
def prop = new Properties()
prop.setProperty("version", fullVersion)
def propFile = new File(subdir, "retz-client.properties")
propFile.createNewFile()
propFile.withOutputStream { out ->
prop.store(out, null)
}
}
project(':retz-planner-spi') {
dependencies {
compile project(":retz-common")
compile 'org.slf4j:slf4j-api:1.7.25'
}
}
project(':retz-server') {
apply plugin: 'application'
apply plugin: "com.github.johnrengelman.shadow"
apply plugin: 'nebula.ospackage'
apply plugin: 'nebula.ospackage-application-daemon'
dependencies {
compile project(":retz-common")
compile project(":retz-planner-spi")
compile 'org.slf4j:slf4j-api:1.7.25'
compile group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.3'
compile 'commons-cli:commons-cli:1.4'
compile 'commons-io:commons-io:2.5'
compile group: 'com.j256.simplejmx', name: 'simplejmx', version: '1.15'
compile 'org.apache.mesos:mesos:1.3.0'
compile 'com.sparkjava:spark-core:2.6.0'
compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.8.9'
compile 'com.h2database:h2:1.4.+'
compile group: 'org.postgresql', name: 'postgresql', version: '42.1.+'
compile group: 'org.apache.tomcat', name: 'tomcat-jdbc', version: '8.5.+'
compile group: 'org.flywaydb', name: 'flyway-core', version: '4.2.+'
testCompile project(":retz-client")
testCompile project(":retz-admin")
}
task processResources.doLast {
makePropertyFile("${buildDir}", "main", project.name, project.version)
}
task processTestResources.doLast {
makePropertyFile("${buildDir}", "test", project.name, project.version)
}
run {
if (project.hasProperty('args')) {
args project.args.split('\\s+')
}
}
mainClassName = 'io.github.retz.scheduler.Launcher'
spotbugs.excludeFilter = file("config/findbugs/excludeFilter.xml")
ospackage {
os = LINUX
user = "root"
summary = "A Job Scheduler on Mesos"
license = "Apache 2.0"
packager = 'Nautilus Technologies, Inc.'
url = "https://retz.github.io/"
}
buildRpm {
release = '1.el7'
arch = 'X86_64'
into '/opt/retz-server'
from('src/main/dist/etc') {
fileType CONFIG | NOREPLACE
into 'etc'
}
}
buildDeb {
configurationFile('/opt/retz-server/etc/retz.properties')
arch = 'AMD64'
}
configurations.archives.artifacts.removeAll { entry ->
entry.type == 'zip' || entry.type == 'tar'
}
}
project(':retz-client') {
apply plugin: 'application'
apply plugin: 'nebula.ospackage-application'
apply plugin: "com.github.johnrengelman.shadow"
dependencies {
compile project(":retz-common")
compile 'org.slf4j:slf4j-api:1.7.25'
compile 'org.slf4j:slf4j-simple:1.7.25'
compile "com.beust:jcommander:1.72"
compile 'commons-io:commons-io:2.5'
compile 'io.github.openfeign:feign-jackson:9.5.0'
compile 'io.github.openfeign:feign-slf4j:9.5.0'
}
task processResources.doLast {
makeClientPropertyFile("${buildDir}", "main", project.name, project.version)
}
task processTestResources.doLast {
makeClientPropertyFile("${buildDir}", "test", project.name, project.version)
}
run {
if (project.hasProperty('args')) {
args project.args.split('\\s+')
}
}
mainClassName = 'io.github.retz.cli.Launcher'
// Won't set max heap size as large file download may happen
applicationDefaultJvmArgs = ["-Xms8m", "-XX:+UseSerialGC"]
ospackage {
os = LINUX
user = 'root' // https://github.com/nebula-plugins/gradle-ospackage-plugin/issues/13
}
buildRpm {
release = '1.el7'
arch = 'X86_64'
into '/opt/retz-client'
from('src/main/dist/etc') {
fileType CONFIG | NOREPLACE
into 'etc'
}
}
buildDeb {
arch = 'AMD64'
configurationFile('/opt/retz-client/etc/retz.properties')
}
configurations.archives.artifacts.removeAll { entry ->
entry.type == 'zip' || entry.type == 'tar'
}
}
project('retz-admin') {
apply plugin: 'java'
apply plugin: 'application'
apply plugin: 'nebula.ospackage-application'
apply plugin: "com.github.johnrengelman.shadow"
dependencies {
compile project(":retz-common")
testCompile group: 'junit', name: 'junit', version: '4.12'
compile 'org.slf4j:slf4j-api:1.7.25'
compile 'org.slf4j:slf4j-simple:1.7.25'
compile group: 'com.j256.simplejmx', name: 'simplejmx', version: '1.15'
compile "com.beust:jcommander:1.72"
}
mainClassName = 'io.github.retz.admin.Launcher'
// Won't set max heap size as large file download may happen
applicationDefaultJvmArgs = ["-Xms8m", "-XX:+UseSerialGC"]
ospackage {
os = LINUX
user = 'root' // https://github.com/nebula-plugins/gradle-ospackage-plugin/issues/13
}
buildRpm {
release = '1.el7'
arch = 'X86_64'
}
buildDeb {
arch = 'AMD64'
}
configurations.archives.artifacts.removeAll { entry ->
entry.type == 'zip' || entry.type == 'tar'
}
}
project('retz-inttest') {
dependencies {
testCompile project(":retz-client")
testCompile 'com.github.docker-java:docker-java:3.0.10'
testCompile 'io.github.openfeign:feign-jackson:9.5.0'
testCompile 'io.github.openfeign:feign-slf4j:9.5.0'
}
task copyServerJar(type: Copy, dependsOn: ':retz-server:shadowJar') {
from project(":retz-server").shadowJar.archivePath
into "${buildDir}/libs/"
rename(/(retz-server)-.+-(all)/, '$1-$2')
}
task copyClientJar(type: Copy, dependsOn: ':retz-client:shadowJar') {
from project(":retz-client").shadowJar.archivePath
into "${buildDir}/libs/"
rename(/(retz-client)-.+-(all)/, '$1-$2')
}
task copyAdminJar(type: Copy, dependsOn: ':retz-admin:shadowJar') {
from project(":retz-admin").shadowJar.archivePath
into "${buildDir}/libs/"
rename(/(retz-admin)-.+-(all)/, '$1-$2')
}
task copy(dependsOn: ['copyServerJar', 'copyClientJar', 'copyAdminJar'])
// Retz- clients classes brought to build/classes, while bundled resources are not
task processTestResources.doLast {
makeClientPropertyFile("${buildDir}", "test", project.name, project.version)
}
task buildDocker {
doLast {
// Use latest Mesos by default
def mesos_version = System.getProperty('mesos_version', '')
System.err.println("mesos version = ${mesos_version}")
def mesos_package_name = 'mesos'
if (mesos_version != null && ! mesos_version.isEmpty() ) {
// 1.1.1-2.0.1 and 1.0.3-2.0.1 are not supported
// run `yum --showduplicates list mesos` to know all available packages at Mesosphere repository
def supported_mesos_versions = ['1.2.1-2.0.1', '1.2.2-2.0.1',
'1.3.0-2.0.3', '1.3.1-2.0.1',
'1.4.0-2.0.1', '1.4.1-2.0.1']
if (! supported_mesos_versions.contains(mesos_version)) {
System.err.println("Mesos version should be one of " + supported_mesos_versions + " but is: " + mesos_version)
exit
}
mesos_package_name = "mesos-${mesos_version}"
}
System.err.println("mesos package name = ${mesos_package_name}")
exec {
executable "docker"
args "build", "-t", "mesos-retz", "--build-arg",
"MESOS_PACKAGE_NAME=${mesos_package_name}",
"${projectDir}/src/test/resources/docker"
}
}
}
test {
// Execute test suites only if "inttest" property is explicitly passed,
// like "gradlew test -Dinttest"
ext.integration = System.getProperty('inttest', 'false') != 'false'
inputs.property 'integration', integration
if (integration) {
dependsOn buildDocker, copy
}
onlyIf { integration }
}
task cleanDockerIamges {
doLast {
exec {
executable "sh"
args "-c", "docker images -q -f dangling=true | xargs docker rmi"
}
}
}
}
task wrapper(type: Wrapper) {
gradleVersion = '4.1'
distributionType = 'ALL'
}
buildScan {
licenseAgreementUrl = 'https://gradle.com/terms-of-service'
licenseAgree = 'yes'
link 'GitHub', 'https://github.com/retz/retz'
}