forked from Netflix/genie
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
488 lines (417 loc) · 15.1 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
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
import com.github.spotbugs.snom.SpotBugsTask
import org.springframework.boot.gradle.plugin.SpringBootPlugin
buildscript {
repositories {
mavenCentral()
gradlePluginPortal()
}
dependencies {
classpath "com.netflix.nebula:gradle-aggregate-javadocs-plugin:3.0.1"
}
}
plugins {
id "com.github.kt3k.coveralls" version "2.10.2"
id "nebula.netflixoss" version "9.2.2"
id "org.ajoberstar.grgit" version "4.1.0"
id "org.ajoberstar.git-publish" version "3.0.0"
id "org.springframework.boot" version "${spring_boot_version}" apply false
id "org.asciidoctor.jvm.convert" version "3.3.0" apply false
id "com.gorylenko.gradle-git-properties" version "2.2.4" apply false
id "com.google.protobuf" version "0.8.14" apply false
id "io.franzbecker.gradle-lombok" version "4.0.0" apply false
id "nebula.node" version "1.4.1" apply false
id "com.github.spotbugs" version "4.6.0" apply false
}
apply plugin: "nebula-aggregate-javadocs"
ext.githubProjectName = rootProject.name
def javaProjects = subprojects.findAll {
it.name != "genie-demo" && it.name != "genie-ddl" && it.name != "genie-docs"
}
allprojects {
apply plugin: "jacoco"
apply plugin: "idea"
apply plugin: "eclipse"
repositories {
mavenCentral()
}
}
idea {
project {
jdkName = "1.8"
languageLevel = "8"
vcs = "Git"
}
}
configure(javaProjects) {
apply plugin: "nebula.netflixoss"
apply plugin: "java"
apply plugin: "checkstyle"
apply plugin: "com.github.spotbugs"
apply plugin: "io.spring.dependency-management"
apply plugin: "com.gorylenko.gradle-git-properties"
apply plugin: "groovy"
apply plugin: "io.franzbecker.gradle-lombok"
apply plugin: "nebula.facet"
group = "com.netflix.${githubProjectName}"
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
facets {
smokeTest {
parentSourceSet = "test"
// includeInCheckLifecycle = false
}
integTest {
parentSourceSet = "test"
testTaskName = "integrationTest"
// includeInCheckLifecycle = false
}
}
dependencyManagement {
imports {
mavenBom SpringBootPlugin.BOM_COORDINATES
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${spring_cloud_version}"
mavenBom "com.google.protobuf:protobuf-bom:${protobuf_version}"
mavenBom "com.squareup.okhttp3:okhttp-bom:4.9.0"
mavenBom "io.grpc:grpc-bom:1.33.1"
mavenBom "org.spockframework:spock-bom:2.0-M4-groovy-2.5"
mavenBom "org.testcontainers:testcontainers-bom:1.15.0"
}
dependencies {
dependency("com.beust:jcommander:1.81")
dependency("cglib:cglib-nodep:3.3.0")
dependency("com.github.fge:json-patch:1.9")
dependency("com.github.ppodgorsek:spring-test-dbunit-core:5.2.0")
dependency("com.github.spotbugs:spotbugs-annotations:4.2.0")
dependencySet(group: "com.squareup.retrofit2", version: "2.8.1") {
entry "retrofit"
entry "converter-jackson"
}
dependency("com.google.guava:guava:20.0")
dependency("commons-io:commons-io:2.6")
dependency("commons-validator:commons-validator:1.7")
dependency("io.springfox:springfox-boot-starter:3.0.0")
dependency("jakarta.el:jakarta.el-api:3.0.3")
dependency("net.sf.jtidy:jtidy:r938")
dependency("net.jcip:jcip-annotations:1.0")
dependency("org.apache.commons:commons-configuration2:2.7")
dependency("org.apache.commons:commons-exec:1.3")
dependency("org.apache.commons:commons-text:1.8")
dependency("org.apache.tika:tika-core:1.25")
dependency("org.apache.maven:maven-artifact:3.6.3")
dependency("org.apache.zookeeper:zookeeper:3.5.8")
dependency("org.codehaus.groovy:groovy-all:2.5.13")
dependency("org.codehaus.janino:janino:3.1.2")
dependency("org.dbunit:dbunit:2.7.0")
}
}
ext {
generatedSourcesDir = file("${buildDir}/generated/sources")
generatedSourcesJavaDir = file("${project.generatedSourcesDir}/main/java")
}
sourceSets {
main {
java {
srcDir project.generatedSourcesJavaDir
}
}
}
idea.module {
sourceDirs += project.generatedSourcesJavaDir
generatedSourceDirs += project.generatedSourcesJavaDir
}
configurations {
all*.exclude group: "javax.servlet", module: "servlet-api"
all*.exclude group: "org.springframework.boot", module: "spring-boot-starter-logging"
}
dependencies {
/*******************************
* Annotation Processors
*******************************/
annotationProcessor("net.jcip:jcip-annotations")
annotationProcessor("com.github.spotbugs:spotbugs-annotations")
/*******************************
* Compile Dependencies
*******************************/
/*******************************
* Compile Only Dependencies
*******************************/
compileOnly("net.jcip:jcip-annotations")
compileOnly("com.github.spotbugs:spotbugs-annotations")
/*******************************
* Runtime Only Dependencies
*******************************/
/*******************************
* Test Dependencies
*******************************/
testAnnotationProcessor("net.jcip:jcip-annotations")
testAnnotationProcessor("com.github.spotbugs:spotbugs-annotations")
testImplementation("cglib:cglib-nodep")
testImplementation("org.spockframework:spock-core")
// Needed to support JUnit 4 Rules that we still can't get away from (e.g. GRpcServerRule) in test files
testImplementation("org.spockframework:spock-junit4")
testImplementation("org.spockframework:spock-spring")
testImplementation("org.springframework.boot:spring-boot-starter-test")
testImplementation("org.junit.jupiter:junit-jupiter-api")
testImplementation("org.junit.jupiter:junit-jupiter-params")
testCompileOnly("net.jcip:jcip-annotations")
testCompileOnly("com.github.spotbugs:spotbugs-annotations")
testRuntimeOnly("jakarta.el:jakarta.el-api")
testRuntimeOnly("org.glassfish:jakarta.el")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine")
}
task removeGeneratedSources(type: Delete) {
project.generatedSourcesDir.deleteDir()
}
task removeIdeaOutDirectory(type: Delete) {
file("${projectDir}/out").deleteDir()
}
clean {
dependsOn(removeIdeaOutDirectory)
}
compileJava {
options.annotationProcessorGeneratedSourcesDirectory = project.generatedSourcesJavaDir
options.compilerArgs += [
"-Xlint:unchecked",
"-Xlint:deprecation",
"-s",
project.generatedSourcesJavaDir
]
}
compileTestJava {
options.compilerArgs += [
"-Xlint:unchecked",
"-Xlint:deprecation"
]
}
tasks.withType(Test) {
task ->
// Use JUnit 5 with Jupiter
useJUnitPlatform()
// set heap size for the test JVM(s)
minHeapSize = "256m"
maxHeapSize = "2g"
// Environment properties to be forwarded to the test runtime
[
"CI",
"INTEGRATION_TEST_DB",
].each { envVariableName ->
if (System.getenv(envVariableName) != null) {
systemProperty envVariableName, System.getenv(envVariableName)
}
}
if (System.env."TRAVIS" == "true") {
systemProperty "spring.profiles.include", "travisci"
}
reports.html.setDestination(new File("${reporting.baseDir}/test/${task.name}"))
jacocoTestReport.getExecutionData().plus(files("$buildDir/jacoco/${task.name}.exec"))
// Customize test logging on CI and everywhere else
testLogging {
if (System.getenv("CI") != null) {
events "passed", "skipped", "failed"
exceptionFormat "full"
} else {
events "failed"
}
}
}
license {
ignoreFailures false
}
checkstyle {
toolVersion = "8.27"
}
spotbugs {
excludeFilter = new File("$rootProject.projectDir/config/spotbugs/excludeFilter.xml")
}
spotbugsTest.enabled = false
spotbugsIntegTest.enabled = false
spotbugsSmokeTest.enabled = false
tasks.withType(SpotBugsTask) {
reports {
xml.enabled = false
html.enabled = true
}
}
jacocoTestReport {
reports {
html.enabled = true
xml.enabled = true
csv.enabled = false
}
}
}
/**********************************
* Coverage Tasks
**********************************/
task codeCoverageReport(type: JacocoReport, group: "Coverage reports") {
executionData fileTree(project.rootDir.absolutePath).include("**/build/jacoco/*.exec")
dependsOn javaProjects*.test
javaProjects.each {
sourceSets it.sourceSets.main
}
reports {
xml.enabled = true
xml.destination new File("${buildDir}/reports/jacoco/report.xml")
html.enabled = true
html.destination new File("${buildDir}/reports/jacoco/html")
csv.enabled = false
}
afterEvaluate {
// Exclude generated files from top-level coverage report
classDirectories.setFrom(
files(
classDirectories.files.collect {
fileTree(
dir: it,
exclude: [
"**/com/netflix/genie/proto/**",
"**/com/netflix/genie/web/data/entities/*_*",
]
)
}
)
)
}
}
coveralls {
sourceDirs = javaProjects.sourceSets.main.allSource.srcDirs.flatten()
jacocoReportPath = "${project.buildDir}/reports/jacoco/report.xml"
}
tasks.coveralls {
group = "Coverage reports"
description = "Uploads the aggregated coverage report to Coveralls"
dependsOn codeCoverageReport
onlyIf {
System.env."CI"
}
}
/**********************************
* Github Pages Tasks
**********************************/
task collectDocumentation(group: "documentation", description: "Copy the documentation from sub-projects") {
dependsOn "aggregateJavadocs"
def restDocs = new File(project(":genie-web").buildDir, "docs/asciidoc")
def referenceDocs = new File(project(":genie-docs").buildDir, "docs/asciidoc")
def demoDocs = new File(project(":genie-demo").buildDir, "docs/asciidoc")
def dockerCompose = new File(project(":genie-demo").projectDir, "src/main/docker/docker-compose.yml")
def docsDir = new File(project.buildDir, "docs")
inputs.dir restDocs
inputs.dir referenceDocs
inputs.dir demoDocs
inputs.file dockerCompose
outputs.dir docsDir
doLast {
copy {
from dockerCompose
into new File(docsDir, "demo")
filter {
it.replace('${GENIE_VERSION}', project.version.toString())
}
}
copy {
from restDocs
into new File(docsDir, "rest")
}
copy {
from referenceDocs
into new File(docsDir, "reference")
}
copy {
from demoDocs
into new File(docsDir, "demo")
}
}
}
gitPublish {
branch = "gh-pages"
contents {
into("docs/${project.version}/") {
from "${project.buildDir}/docs/"
}
into("_releases") {
from new File(project(":genie-docs").projectDir, "src/templates/releaseTemplate.md")
rename {
String fileName -> fileName.replace("releaseTemplate", "${project.version}")
}
filter {
it.replace("GENIE_VERSION", project.version.toString())
}
}
}
preserve {
include "**/*"
exclude "docs/${project.version}/"
}
commitMessage = "Documentation generated for ${project.version} by Travis Build ${System.env.TRAVIS_BUILD_NUMBER}".toString()
}
gitPublishCopy {
// This also depends on asciidoctor task for some sub-projects but that dependency is reverse mapped in the
// pertinent sub-project build file
dependsOn tasks.collectDocumentation
}
gitPublishPush {
onlyIf {
System.env."CI"
}
}
/**********************************
* Docker Tasks
**********************************/
ext.isDockerRunning = {
def dummyOutputStream = new OutputStream() {
@Override
void write(int b) {}
}
// See: https://docs.docker.com/config/daemon/#check-whether-docker-is-running
def dockerRunning = exec {
executable "docker"
args "info"
ignoreExitValue true
standardOutput dummyOutputStream
errorOutput dummyOutputStream
}
if (dockerRunning.exitValue != 0) {
println("Docker not running.")
}
return dockerRunning.exitValue == 0
}
ext.getDockerTags = { String appName, String projectVersion ->
def tags = ["netflixoss/${appName}:${projectVersion}"]
if (!projectVersion.contains("SNAPSHOT") && !projectVersion.contains("-rc.")) {
tags.add("netflixoss/${appName}:latest")
tags.add("netflixoss/${appName}:latest.release")
} else if (projectVersion.contains("-rc.")) {
tags.add("netflixoss/${appName}:latest.candidate")
} else {
tags.add("netflixoss/${appName}:latest.snapshot")
}
return tags
}
task dockerLogout(type: Exec, group: "Docker", description: "Logout of docker hub") {
onlyIf {
rootProject.ext.isDockerRunning()
}
commandLine "docker", "logout"
}
task dockerLogin(type: Exec, group: "Docker", description: "Login to docker hub using DOCKER_USER and DOCKER_PASSWORD environment variables") {
onlyIf {
rootProject.ext.isDockerRunning()
}
dependsOn tasks.dockerLogout
commandLine "docker", "login", "-u", System.getenv("DOCKER_USER") ?: "", "-p", System.getenv("DOCKER_PASSWORD") ?: ""
}
task dockerBuildAllImages(group: "Docker", description: "Container task for all docker image builds") {
onlyIf {
rootProject.ext.isDockerRunning()
}
dependsOn ":genie-app:dockerBuildAppImage"
dependsOn ":genie-demo:dockerBuildApacheImage"
dependsOn ":genie-demo:dockerBuildClientImage"
}
gradleEnterprise {
buildScan {
publishAlways()
termsOfServiceUrl = "https://gradle.com/terms-of-service"
termsOfServiceAgree = "yes"
}
}