-
Notifications
You must be signed in to change notification settings - Fork 209
/
build.gradle
356 lines (332 loc) · 11.6 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
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/
import com.github.jk1.license.render.TextReportRenderer
buildscript {
dependencies {
classpath 'com.github.jk1:gradle-license-report:2.1'
}
}
plugins {
id 'com.diffplug.spotless' version '6.22.0'
id 'io.spring.dependency-management' version '1.1.0'
}
apply from: file("${rootDir}/build-resources.gradle")
allprojects {
apply plugin: 'checkstyle'
apply plugin: 'com.diffplug.spotless'
apply plugin: 'com.github.jk1.dependency-license-report'
ext {
mavenPublicationRootFile = file("${rootProject.buildDir}/m2")
}
spotless {
format 'markdown', {
target '*.md'
// TODO: enrich format rules
endWithNewline()
}
format 'misc', {
target '.gitignore', '*.yml', '*.yaml'
// TODO: enrich format rules
trimTrailingWhitespace()
endWithNewline()
}
}
project.plugins.withType(JavaPlugin).configureEach {
java {
withJavadocJar()
withSourcesJar()
}
}
checkstyle {
toolVersion = '10.12.3'
}
}
subprojects {
apply plugin: 'java'
apply plugin: 'jacoco'
java {
toolchain {
languageVersion = JavaLanguageVersion.of(11)
}
}
spotless {
java {
targetExclude 'build/generated-src/antlr/**'
// TODO: enrich format rules
removeUnusedImports()
}
}
dependencies {
implementation platform('com.fasterxml.jackson:jackson-bom:2.17.2')
implementation platform('org.eclipse.jetty:jetty-bom:9.4.53.v20231009')
implementation platform('io.micrometer:micrometer-bom:1.10.5')
implementation libs.guava.core
implementation libs.slf4j.api
testImplementation testLibs.bundles.junit
testImplementation testLibs.bundles.mockito
testImplementation testLibs.hamcrest
testImplementation testLibs.awaitility
constraints {
implementation('dnsjava:dnsjava') {
version {
require '3.6.1'
}
because 'Fixes CVE-2023-39410.'
}
implementation('org.apache.avro:avro') {
version {
require '1.11.3'
}
because 'Fixes CVE-2023-39410.'
}
implementation('org.apache.commons:commons-configuration2') {
version {
require '2.11.0'
}
because 'Fixes CVE-2024-29131 and CVE-2024-29133.'
}
implementation('org.apache.httpcomponents:httpclient') {
version {
require '4.5.14'
}
because 'We want the newest version of httpclient.'
}
implementation('org.apache.logging.log4j:log4j-core') {
version {
require '2.17.1'
}
because 'Log4j 2.17.1 fixes CVE-2021-44228, CVE-2021-45046, CVE-2021-45105, and CVE-2021-44832'
}
implementation('org.apache.logging.log4j:log4j-api') {
version {
require '2.17.1'
}
because 'the build fails if the Log4j API is not update along with log4j-core'
}
implementation('org.apache.zookeeper:zookeeper') {
version {
require '3.8.4'
}
because 'Fixes CVE-2024-23944, CVE-2023-44981'
}
implementation('com.google.code.gson:gson') {
version {
require '2.8.9'
}
because 'Fixes WS-2021-0419 DoS vulnerability'
}
implementation('com.google.protobuf:protobuf-java') {
version {
require '3.21.11'
}
because 'Fixes CVE-2022-3509, CVE-2022-3510'
}
implementation('org.yaml:snakeyaml') {
version {
require '2.0'
}
because 'Fixes CVE-2022-1471'
}
implementation('org.codehaus.jettison:jettison') {
version {
require '1.5.4'
}
because 'CVE from transitive dependecies'
}
implementation('net.minidev:json-smart') {
version {
require '2.5.0'
}
because 'CVE from transitive dependencies'
}
implementation('org.jetbrains.kotlin:kotlin-stdlib') {
version {
require '1.8.21'
}
because 'CVE from transitive dependencies'
}
implementation('org.eclipse.jetty:http2-common') {
version {
require '9.4.53.v20231009'
}
because 'Fixes CVE-2023-44487'
}
implementation('org.eclipse.jetty:http2-server') {
version {
require '9.4.53.v20231009'
}
because 'Fixes CVE-2023-44487'
}
implementation('org.xerial.snappy:snappy-java') {
version {
require '1.1.10.5'
}
because 'Fixes CVE-2023-43642'
}
implementation('com.squareup.okio:okio-jvm') {
version {
require '3.5.0'
}
because 'CVE from transitive dependencies'
}
implementation('com.charleskorn.kaml:kaml') {
version {
require '0.55.0'
}
because 'CVE from transitive dependencies'
}
implementation('com.jayway.jsonpath:json-path') {
version {
require '2.9.0'
}
because 'Fixes CVE-2023-51074 from transitive dependencies'
}
implementation('org.scala-lang:scala-library') {
version {
require '2.13.12'
}
because 'CVE from transitive dependencies'
}
implementation('org.jline:jline') {
version {
require '3.25.0'
}
because 'CVE-2023-50572'
}
implementation('org.json:json') {
version {
require '20231013'
}
because 'CVE-2023-5072, CVE from transitive dependencies'
}
implementation('org.apache.commons:commons-compress') {
version {
require '1.26.0'
}
because 'CVE-2024-25710, CVE-2024-26308'
}
}
}
configurations.all {
resolutionStrategy.eachDependency { def details ->
if (details.requested.group == 'io.netty') {
if (details.requested.name == 'netty') {
details.useTarget group: 'io.netty', name: 'netty-all', version: '4.1.108.Final'
details.because 'Fixes CVE-2022-41881, CVE-2021-21290 and CVE-2022-41915.'
} else if (!details.requested.name.startsWith('netty-tcnative')) {
details.useVersion '4.1.108.Final'
details.because 'Fixes CVE-2022-41881, CVE-2021-21290 and CVE-2022-41915.'
}
} else if (details.requested.group == 'log4j' && details.requested.name == 'log4j') {
details.useTarget group: 'org.apache.logging.log4j', name: 'log4j-1.2-api', version: '2.17.1'
} else if (details.requested.group == 'org.bouncycastle' && details.requested.name.endsWith('-jdk15on')) {
def java8Name = details.requested.name.replace('-jdk15on', '-jdk18on')
details.useTarget group: 'org.bouncycastle', name: java8Name, version: libs.bouncycastle.bcprov.get().version
details.because 'Use only the Java 8 artifacts of BouncyCastle'
}
}
}
test {
useJUnitPlatform()
javaLauncher = javaToolchains.launcherFor {
languageVersion = JavaLanguageVersion.current()
}
testLogging {
exceptionFormat "full"
showStackTraces false
}
reports {
junitXml.required
html.required
}
}
build.dependsOn test
jacocoTestReport {
dependsOn test // tests are required to run before generating the report
reports {
xml.required
html.required
}
}
task allDeps(type: DependencyReportTask) {}
}
configure(subprojects.findAll {it.name != 'data-prepper-api'}) {
dependencies {
implementation platform('software.amazon.awssdk:bom:2.25.11')
implementation 'jakarta.validation:jakarta.validation-api:3.0.2'
}
}
configure(coreProjects) {
jacocoTestReport {
dependsOn test // tests are required to run before generating the report
reports {
xml.required
csv.required
html.destination file("${buildDir}/reports/jacocoHtml")
}
}
test {
finalizedBy jacocoTestReport // report is always generated after tests run
}
jacocoTestCoverageVerification {
dependsOn jacocoTestReport
violationRules {
rule {
limit {
minimum = 0.65 //TODO increase this to 0.75
}
}
}
}
check.dependsOn jacocoTestCoverageVerification
}
task generateAggregateTestReport(type: TestReport) {
destinationDirectory = file("${layout.buildDirectory}/reports/tests")
reportOn subprojects*.test
}
licenseReport {
excludeOwnGroup = true
excludeBoms = true
excludes = ['software.amazon.awssdk:bom']
renderers = new TextReportRenderer()
}
task generateThirdPartyReport(type: Copy) {
from 'build/reports/dependency-license/'
into '.'
include 'THIRD-PARTY-NOTICES.txt'
rename 'THIRD-PARTY-NOTICES.txt', 'THIRD-PARTY'
generateThirdPartyReport.dependsOn(generateLicenseReport)
}
// Utility method to recursively collect tasks from all projects and subprojects
def collectTasksRecursively(Project project, String taskName) {
def tasks = []
if (project.plugins.hasPlugin('java') || project.plugins.hasPlugin('java-library')) {
Task task = project.tasks.findByName(taskName)
if (task != null) {
tasks.add(task)
}
}
project.subprojects.each { subproject ->
tasks += collectTasksRecursively(subproject, taskName)
}
return tasks
}
// Define a release task that depends on 'assemble' and 'publish' tasks of all nested projects within the coreProjects
task release {
doLast {
println "Release task completed."
}
}
// Iterate over each core project and collect 'assemble' and 'publish' tasks recursively from them and their nested subprojects
coreProjects.each { coreProject ->
// Ensure that the core project and its subprojects are evaluated
evaluationDependsOn(coreProject.path)
// Recursively collect 'assemble' and 'publishToMavenLocal' tasks for the core project
def assembleTasks = collectTasksRecursively(coreProject, 'assemble')
def publishTasks = collectTasksRecursively(coreProject, 'publish')
// Add these tasks as dependencies of the release task
release.dependsOn assembleTasks
release.dependsOn publishTasks
}