forked from linkedin/cruise-control
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
520 lines (453 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
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
/*
* Copyright 2017 LinkedIn Corp. Licensed under the BSD 2-Clause License (the "License"). See License in the project root for license information.
*/
import com.linkedin.gradle.build.DistributeTask
plugins {
id "com.jfrog.artifactory"
id "idea"
id "jacoco" // Java Code Coverage plugin
id "com.github.ben-manes.versions" version "0.42.0"
id "com.github.spotbugs" version "6.0.6" apply false
id "checkstyle"
id "org.openapi.generator" version "5.3.0"
}
group = 'com.linkedin.cruisecontrol'
project.ext {
pomConfig = {
url "https://github.com/linkedin/cruise-control"
licenses {
license {
name "BSD 2-CLAUSE LICENSE"
url "https://opensource.org/licenses/BSD-2-Clause"
}
}
developers {
developer {
name "Adem Efe Gencer"
email "[email protected]"
}
developer {
name "Jiangjie (Becket) Qin"
email "[email protected]"
}
developer {
name "Sir Joel Koshy"
email "[email protected]"
}
}
scm {
url "https://github.com/linkedin/cruise-control"
}
}
buildVersionFileName = "cruise-control-version.properties"
commitId = project.hasProperty('commitId') ? commitId : null
scalaBinaryVersion = getScalaBinaryVersion(scalaVersion)
}
allprojects {
repositories {
mavenCentral()
}
apply plugin: 'com.github.ben-manes.versions'
dependencyUpdates {
revision="release"
resolutionStrategy {
componentSelection { rules ->
rules.all { ComponentSelection selection ->
boolean rejected = ['snap', 'alpha', 'beta', 'rc', 'cr', 'm'].any { qualifier ->
selection.candidate.version ==~ /(?i).*[.-]${qualifier}[.\d-]*/
}
if (rejected) {
selection.reject('Release candidate')
}
}
}
}
}
}
subprojects {
group = rootProject.group
version = rootProject.version
apply plugin: 'java'
apply plugin: 'java-library'
apply plugin: 'checkstyle'
apply plugin: 'maven-publish'
apply plugin: "com.github.spotbugs"
apply plugin: 'jacoco'
// This project requires Java 11
sourceCompatibility = JavaVersion.VERSION_11
task sourcesJar(type: Jar, dependsOn: classes) {
archiveClassifier.set("sources")
from sourceSets.main.allSource
}
task javadocJar(type: Jar, dependsOn: javadoc) {
archiveClassifier.set("javadoc")
from javadoc.destinationDir
}
//code quality and inspections
checkstyle {
toolVersion = '10.0'
ignoreFailures = false
configDirectory = file("$rootDir/checkstyle")
}
spotbugs {
toolVersion = '4.7.1'
excludeFilter = file("$rootDir/gradle/findbugs-exclude.xml")
ignoreFailures = false
jvmArgs = [ '-Xms512m' ]
maxHeapSize = '768m'
showProgress = true
}
spotbugsMain {
reports {
xml.enabled = (project.hasProperty('xmlFindBugsReport'))
html.enabled = (!project.hasProperty('xmlFindBugsReport'))
}
}
spotbugsTest {
reports {
xml.enabled = (project.hasProperty('xmlFindBugsReport'))
html.enabled = (!project.hasProperty('xmlFindBugsReport'))
}
}
// aggregated task for checkstyle and spotbugs static analyzers
task('analyze') {
dependsOn('checkstyleMain', 'checkstyleTest', 'spotbugsMain', 'spotbugsTest')
doLast {}
}
test.dependsOn('checkstyleMain', 'checkstyleTest', 'spotbugsMain', 'spotbugsTest')
jar {
from "$rootDir/LICENSE"
from "$rootDir/NOTICE"
}
test {
useJUnit {}
testLogging {
events "passed", "failed", "skipped"
exceptionFormat = 'full'
}
if (!project.hasProperty("maxParallelForks")) {
maxParallelForks = Runtime.runtime.availableProcessors()
}
finalizedBy jacocoTestReport
}
jacocoTestReport {
reports {
xml.required = false
csv.required = false
html.outputLocation = layout.buildDirectory.dir('jacocoHtml')
}
}
}
project(':cruise-control-core') {
apply plugin: 'maven-publish'
apply plugin: 'com.jfrog.artifactory'
configurations {
testOutput
}
dependencies {
configurations.all {
exclude group: 'org.slf4j', module: 'slf4j-log4j12'
exclude group: 'log4j', module: 'log4j'
}
implementation "org.slf4j:slf4j-api:1.7.36"
implementation "org.apache.logging.log4j:log4j-slf4j-impl:2.17.2"
implementation 'org.apache.commons:commons-math3:3.6.1'
api "org.eclipse.jetty:jetty-servlet:${jettyVersion}"
implementation 'com.google.code.findbugs:jsr305:3.0.2'
api "io.vertx:vertx-core:${vertxVersion}"
api "io.vertx:vertx-web:${vertxVersion}"
testImplementation 'junit:junit:4.13.2'
testOutput sourceSets.test.output
}
publishing {
publications {
java(MavenPublication) {
from components.java
artifact sourcesJar
artifact javadocJar
pom.withXml {
def root = asNode()
root.appendNode('name', 'cruise-control-core')
root.appendNode('description', 'cruise control core related')
root.children().last() + rootProject.ext.pomConfig
}
}
}
}
artifactoryPublish.dependsOn assemble
artifactoryPublish.dependsOn publishToMavenLocal
sourceSets {
main {
java {
srcDirs = ['src/main/java']
}
}
test {
java {
srcDirs = ['src/test/java']
}
}
}
}
project(':cruise-control') {
apply plugin: 'scala'
apply plugin: 'maven-publish'
apply plugin: 'com.jfrog.artifactory'
//needed because our java classes depend on scala classes, so must be compiled by scala
sourceSets {
main {
java {
srcDirs = []
}
scala {
srcDirs = ['src/main/java', 'src/main/scala']
}
}
test {
java {
srcDirs = []
}
scala {
srcDirs = ['src/test/java', 'src/test/scala']
}
}
integrationTest {
java {
srcDirs = ["src/integrationTest/java"]
}
resources {
srcDirs = ['src/integrationTest/resources']
}
compileClasspath += main.output + test.output
runtimeClasspath += main.output + test.output
}
}
configurations {
integrationTestImplementation.extendsFrom testImplementation
integrationTestRuntime.extendsFrom testRuntime
}
dependencies {
configurations.all {
exclude group: 'org.slf4j', module: 'slf4j-log4j12'
exclude group: 'log4j', module: 'log4j'
}
api project(':cruise-control-metrics-reporter')
api project(':cruise-control-core')
implementation "org.slf4j:slf4j-api:1.7.36"
implementation "org.apache.logging.log4j:log4j-slf4j-impl:2.17.2"
implementation "org.apache.zookeeper:zookeeper:${zookeeperVersion}"
implementation "io.netty:netty-handler:${nettyVersion}"
implementation "io.netty:netty-transport-native-epoll:${nettyVersion}"
api "org.apache.kafka:kafka_$scalaBinaryVersion:$kafkaVersion"
api "org.apache.kafka:kafka-clients:$kafkaVersion"
// Add following dependency when upgrading to Kafka 3.5
api "org.apache.kafka:kafka-storage:$kafkaVersion"
implementation "org.scala-lang:scala-library:$scalaVersion"
implementation 'org.apache.commons:commons-math3:3.6.1'
implementation 'org.apache.httpcomponents:httpclient:4.5.13'
implementation 'commons-codec:commons-codec:1.15'
implementation 'com.google.code.gson:gson:2.9.0'
implementation "org.eclipse.jetty:jetty-server:${jettyVersion}"
implementation 'io.dropwizard.metrics:metrics-jmx:4.2.9'
implementation 'com.nimbusds:nimbus-jose-jwt:9.24'
implementation 'io.swagger.parser.v3:swagger-parser-v3:2.1.16'
implementation 'io.github.classgraph:classgraph:4.8.141'
implementation 'com.google.code.findbugs:jsr305:3.0.2'
// Temporary pin for vulnerability
implementation 'com.fasterxml.jackson.core:jackson-databind:2.15.2'
api "io.vertx:vertx-web-openapi:${vertxVersion}"
api "io.vertx:vertx-core:${vertxVersion}"
api "io.vertx:vertx-web:${vertxVersion}"
api "io.vertx:vertx-junit5:${vertxVersion}"
api 'io.swagger.core.v3:swagger-annotations:2.0.2'
api 'io.swagger.core.v3:swagger-core:2.0.2'
api 'com.google.guava:guava:32.1.3-jre'
api 'org.json:json:20231013'
api 'org.xerial.snappy:snappy-java:1.1.10.1'
testImplementation project(path: ':cruise-control-metrics-reporter', configuration: 'testOutput')
testImplementation project(path: ':cruise-control-core', configuration: 'testOutput')
testImplementation "org.scala-lang:scala-library:$scalaVersion"
testImplementation 'junit:junit:4.13.2'
testImplementation 'org.easymock:easymock:4.3'
testImplementation "org.apache.kafka:kafka_$scalaBinaryVersion:$kafkaVersion:test"
testImplementation "org.apache.kafka:kafka-clients:$kafkaVersion:test"
testImplementation 'commons-io:commons-io:2.11.0'
testImplementation 'org.apache.httpcomponents:httpclient:4.5.13:tests'
testImplementation 'org.bouncycastle:bcpkix-jdk15on:1.70'
testImplementation 'org.apache.kerby:kerb-simplekdc:2.0.1'
testImplementation 'com.jayway.jsonpath:json-path:2.7.0'
testImplementation 'org.powermock:powermock-module-junit4:2.0.9'
testImplementation 'org.powermock:powermock-api-easymock:2.0.9'
}
publishing {
publications {
java(MavenPublication) {
from components.java
artifact sourcesJar
artifact javadocJar
pom.withXml {
def root = asNode()
root.appendNode('name', 'cruise-control')
root.appendNode('description', 'cruise control related')
root.children().last() + rootProject.ext.pomConfig
}
}
}
}
artifactoryPublish.dependsOn assemble
artifactoryPublish.dependsOn publishToMavenLocal
tasks.create(name: "copyDependantLibs", type: Copy) {
from (configurations.testRuntimeClasspath) {
include('log4j-slf4j-impl*')
}
from (configurations.runtimeClasspath) {
}
into "$buildDir/dependant-libs"
duplicatesStrategy 'exclude'
}
tasks.create(name: "buildFatJar", type: Jar, dependsOn: ["createVersionFile", ":cruise-control-metrics-reporter:jar", ":cruise-control-core:jar"]) {
archiveBaseName = project.name + '-all'
duplicatesStrategy = DuplicatesStrategy.INCLUDE
from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } }
manifest {
attributes("Multi-Release": true)
}
with jar
}
compileScala.finalizedBy(tasks.copyDependantLibs)
task determineCommitId {
def takeFromHash = 40
if (commitId) {
commitId = commitId.take(takeFromHash)
} else if (file("$rootDir/.git/HEAD").exists()) {
def headRef = file("$rootDir/.git/HEAD").text
if (headRef.contains('ref: ')) {
headRef = headRef.replaceAll('ref: ', '').trim()
if (file("$rootDir/.git/$headRef").exists()) {
commitId = file("$rootDir/.git/$headRef").text.trim().take(takeFromHash)
}
} else {
commitId = headRef.trim().take(takeFromHash)
}
} else {
commitId = "unknown"
}
}
// Referenced similar method for getting software version in Kafka code.
task createVersionFile(dependsOn: determineCommitId) {
ext.receiptFile = file("$buildDir/cruise-control/$buildVersionFileName")
outputs.file receiptFile
outputs.upToDateWhen { false }
doLast {
def data = [
commitId: commitId,
version: version,
]
receiptFile.parentFile.mkdirs()
def content = data.entrySet().collect { "$it.key=$it.value" }.sort().join("\n")
receiptFile.setText(content, "ISO-8859-1")
}
}
task integrationTest(type: Test) {
testClassesDirs = sourceSets.integrationTest.output.classesDirs
classpath = sourceSets.integrationTest.runtimeClasspath
testLogging {
events "passed", "failed", "skipped"
exceptionFormat = 'full'
}
}
compileIntegrationTestJava.dependsOn copyDependantLibs
jar {
dependsOn createVersionFile
from("$buildDir") {
include "cruise-control/$buildVersionFileName"
}
}
task generateOpenApiJson(type: org.openapitools.generator.gradle.plugin.tasks.GenerateTask) {
inputSpec = "$rootDir/cruise-control/src/main/resources/yaml/base.yaml"
generatorName = "openapi"
outputDir = "$rootDir/cruise-control/src/main/resources/webroot"
}
processResources.dependsOn generateOpenApiJson
compileJava.dependsOn generateOpenApiJson
}
project(':cruise-control-metrics-reporter') {
apply plugin: 'maven-publish'
apply plugin: 'com.jfrog.artifactory'
configurations {
testOutput
}
dependencies {
configurations.all {
exclude group: 'org.slf4j', module: 'slf4j-log4j12'
exclude group: 'log4j', module: 'log4j'
}
implementation "org.slf4j:slf4j-api:1.7.36"
implementation "com.yammer.metrics:metrics-core:2.2.0"
implementation "org.apache.logging.log4j:log4j-slf4j-impl:2.17.2"
implementation "org.apache.kafka:kafka_$scalaBinaryVersion:$kafkaVersion"
implementation "org.apache.kafka:kafka-clients:$kafkaVersion"
implementation 'com.google.code.findbugs:jsr305:3.0.2'
// Temporary pin for vulnerability
implementation 'com.fasterxml.jackson.core:jackson-databind:2.15.2'
testImplementation 'junit:junit:4.13.2'
testImplementation 'org.bouncycastle:bcpkix-jdk15on:1.70'
testImplementation 'org.powermock:powermock-module-junit4:2.0.9'
testImplementation 'org.powermock:powermock-api-easymock:2.0.9'
testImplementation "org.apache.kafka:kafka-clients:$kafkaVersion:test"
testImplementation "org.apache.kafka:kafka-clients:$kafkaVersion"
testImplementation 'commons-io:commons-io:2.11.0'
testImplementation "org.apache.zookeeper:zookeeper:${zookeeperVersion}"
testOutput sourceSets.test.output
}
publishing {
publications {
java(MavenPublication) {
from components.java
artifact sourcesJar
artifact javadocJar
pom.withXml {
def root = asNode()
root.appendNode('name', 'cruise-control-metrics-reporter')
root.appendNode('description', 'cruise control metrics reporter related')
root.children().last() + rootProject.ext.pomConfig
}
}
}
}
artifactoryPublish.dependsOn assemble
artifactoryPublish.dependsOn publishToMavenLocal
}
artifactoryPublish.skip = true
artifactory {
contextUrl = 'https://linkedin.jfrog.io/linkedin'
publish {
repoKey = 'cruise-control'
username = System.getenv('ARTIFACTORY_USER')
password = System.getenv('ARTIFACTORY_KEY')
defaults {
publications ('java')
publishBuildInfo = true
publishArtifacts = true
publishPom = true
publishIvy = true
}
}
clientConfig.setIncludeEnvVars(false)
}
task distributeBuild(type: DistributeTask) {
dependsOn ':artifactoryPublish', ':cruise-control:artifactoryPublish', ':cruise-control-core:artifactoryPublish', ':cruise-control-metrics-reporter:artifactoryPublish'
}
task buildApiWiki(type: Exec) {
workingDir '.'
commandLine './build_api_wiki.sh'
}
static def getScalaBinaryVersion(versionStr) {
String[] versionList = versionStr.split("\\.")
return versionList[0] + "." + versionList[1]
}
//wrapper generation task
wrapper {
gradleVersion = '8.5'
distributionType = Wrapper.DistributionType.ALL
}