-
Notifications
You must be signed in to change notification settings - Fork 75
Expand file tree
/
Copy pathbuild.gradle
More file actions
319 lines (273 loc) · 9.94 KB
/
build.gradle
File metadata and controls
319 lines (273 loc) · 9.94 KB
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
buildscript {
repositories {
maven {
url "https://repo.maven.apache.org/maven2/"
metadataSources {
gradleMetadata()
mavenPom()
artifact()
}
}
maven {
url "https://plugins.gradle.org/m2/"
metadataSources {
gradleMetadata()
mavenPom()
artifact()
}
}
}
dependencies {
classpath "com.diffplug.spotless:spotless-plugin-gradle:6.9.1"
classpath "com.diffplug.spotless:spotless-lib:2.9.0"
classpath "com.diffplug.spotless:spotless-lib-extra:2.9.0"
classpath "com.github.spotbugs:com.github.spotbugs.gradle.plugin:4.8.0"
}
}
ext {
spring_web_version = "2.7.8"
spark_version = "3.1.1"
ok_http3_version = "4.11.0"
junit_version = "5.11.0"
iceberg_1_2_version = "1.2.0.11"
iceberg_1_5_version = "1.5.2.8"
otel_agent_version = "2.12.0" // Bundles OTel SDK 1.47.0
otel_annotations_version = "2.12.0" // Match agent version
}
// OpenTelemetry Java Agent for distributed tracing.
// The agent JAR is not a compile dependency; it is attached at JVM startup via -javaagent.
configurations {
otelAgent
}
dependencies {
otelAgent "io.opentelemetry.javaagent:opentelemetry-javaagent:${otel_agent_version}"
}
tasks.register('downloadOtelAgent', Copy) {
description = 'Downloads the OpenTelemetry Java Agent JAR for distributed tracing'
group = 'observability'
from configurations.otelAgent
into "${rootProject.buildDir}/otel"
rename { 'opentelemetry-javaagent.jar' }
}
group = 'com.linkedin.openhouse'
subprojects {
buildDir = "${rootProject.buildDir}/${project.name}"
group = rootProject.group
version = rootProject.version
}
allprojects {
apply plugin: "com.diffplug.spotless"
apply plugin: "com.github.spotbugs"
group = 'com.linkedin.openhouse'
repositories {
maven {
url "https://repo.maven.apache.org/maven2/"
metadataSources {
gradleMetadata()
mavenPom()
artifact()
}
}
}
def excludedProjects = [
':integrations:spark:spark-3.5:openhouse-spark-3.5-itest',
':apps:openhouse-spark-apps-1.5_2.12'
]
if (!excludedProjects.contains(it.path)) {
configurations.all {
resolutionStrategy {
force 'com.fasterxml.jackson:jackson-bom:2.13.4'
force 'com.fasterxml.jackson.core:jackson-databind:2.13.4'
force 'org.apache.orc:orc-core:1.8.3'
force 'com.google.guava:guava:33.5.0-jre'
}
}
}
plugins.withType(JavaPlugin) {
dependencies {
testImplementation "org.assertj:assertj-core:3.24.2" //assertions library
testImplementation "org.junit.jupiter:junit-jupiter-api:" + junit_version
testImplementation "org.junit.jupiter:junit-jupiter-params:" + junit_version
testImplementation "org.mockito:mockito-core:4.11.0"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:" + junit_version
}
tasks.withType(Test).configureEach {
useJUnitPlatform()
testLogging {
// use these options for analyzing results: --console=plain > output.log 2>&1
events "passed", "skipped", "failed" //, "started"
// showStandardStreams = true
}
beforeTest { descriptor ->
logger.lifecycle("Running test: ${descriptor.className}.${descriptor.name}")
}
}
spotless {
enforceCheck = false
java {
target '**/*.java'
targetExclude 'client/**', 'build/**'
importOrder('', 'static ')
removeUnusedImports()
trimTrailingWhitespace()
endWithNewline()
googleJavaFormat('1.7')
}
}
spotbugs {
includeFilter = rootProject.file('gradle/spotbugs/spotbugsInclude.xml')
excludeFilter = rootProject.file('gradle/spotbugs/spotbugsExclude.xml')
ignoreFailures = true
}
spotbugsMain {
reports {
html {
required = true
outputLocation = file("$buildDir/reports/spotbugs/main/spotbugs.html")
}
}
}
spotbugsTest.enabled = false
}
afterEvaluate {
for (def task in it.tasks) {
if (task != rootProject.tasks.CopyGitHooksTask) {
task.dependsOn rootProject.tasks.CopyGitHooksTask
}
}
}
}
// Local Git Hooks cannot be shared, as .git directory is gitignore'd.
tasks.register('CopyGitHooksTask', Copy) {
println 'Make the git hook available in .git/hooks directory.'
from file('scripts/git-hooks')
into file('.git/hooks/')
}
// =============================================================================
// Docker Build Prerequisites
// =============================================================================
// These tasks make the implicit JAR dependencies for Docker builds explicit.
// Run `./gradlew dockerPrereqs` before `docker compose build`.
//
// JAR Dependencies by Dockerfile:
// tables-service.Dockerfile -> :services:tables:bootJar
// housetables-service.Dockerfile -> :services:housetables:bootJar
// jobs-service.Dockerfile -> :services:jobs:bootJar
// jobs-scheduler.Dockerfile -> :apps:openhouse-spark-apps_2.12:shadowJar (uber JAR)
// spark-base-hadoop2.8.dockerfile ->
// :integrations:spark:spark-3.1:openhouse-spark-runtime_2.12:shadowJar (uber JAR)
// :apps:openhouse-spark-apps_2.12:shadowJar (uber JAR)
// :scripts:java:tools:dummytokens:jar
// spark-3.5-base-hadoop3.2.dockerfile ->
// :integrations:spark:spark-3.5:openhouse-spark-3.5-runtime_2.12:shadowJar (uber JAR)
// :apps:openhouse-spark-apps_2.12:shadowJar (uber JAR)
// :scripts:java:tools:dummytokens:jar
// =============================================================================
tasks.register('dockerPrereqs') {
description = 'Builds all JAR files required by Docker images'
group = 'docker'
// Service bootJars (Spring Boot fat JARs)
dependsOn ':services:tables:bootJar'
dependsOn ':services:housetables:bootJar'
dependsOn ':services:jobs:bootJar'
// Spark runtime uber JARs (shadowJar)
dependsOn ':integrations:spark:spark-3.1:openhouse-spark-runtime_2.12:shadowJar'
dependsOn ':integrations:spark:spark-3.5:openhouse-spark-3.5-runtime_2.12:shadowJar'
// Spark apps uber JAR (shadowJar)
dependsOn ':apps:openhouse-spark-apps_2.12:shadowJar'
// Utility JAR
dependsOn ':scripts:java:tools:dummytokens:jar'
// OpenTelemetry Java Agent
dependsOn 'downloadOtelAgent'
doLast {
println ''
println '============================================================'
println 'Docker prerequisites built successfully!'
println ''
println 'JAR files created:'
println ' build/tables/libs/tables.jar'
println ' build/housetables/libs/housetables.jar'
println ' build/jobs/libs/jobs.jar'
println ' build/openhouse-spark-runtime_2.12/libs/openhouse-spark-runtime_2.12-uber.jar'
println ' build/openhouse-spark-3.5-runtime_2.12/libs/openhouse-spark-3.5-runtime_2.12-uber.jar'
println ' build/openhouse-spark-apps_2.12/libs/openhouse-spark-apps_2.12-uber.jar'
println ' build/dummytokens/libs/dummytokens*.jar'
println ' build/otel/opentelemetry-javaagent.jar'
println ''
println 'Ready for: docker compose build'
println '============================================================'
}
}
tasks.register('dockerBuild', Exec) {
description = 'Builds Docker images after ensuring all JAR prerequisites are built'
group = 'docker'
dependsOn 'dockerPrereqs'
def recipe = project.hasProperty('recipe') ? project.property('recipe') : 'oh-hadoop-spark'
def recipeDir = "${rootDir}/infra/recipes/docker-compose/${recipe}"
workingDir recipeDir
commandLine 'docker', 'compose', 'build'
doFirst {
if (!file(recipeDir).exists()) {
throw new GradleException("Recipe directory not found: ${recipeDir}\n" +
"Available recipes: " + file("${rootDir}/infra/recipes/docker-compose")
.listFiles()
.findAll { it.isDirectory() && it.name != 'common' }
.collect { it.name }
.join(', '))
}
println ''
println "Building Docker images for recipe: ${recipe}"
println "Recipe directory: ${recipeDir}"
println ''
}
}
tasks.register('dockerUp', Exec) {
description = 'Builds JARs, Docker images, and starts containers'
group = 'docker'
dependsOn 'dockerBuild'
def recipe = project.hasProperty('recipe') ? project.property('recipe') : 'oh-hadoop-spark'
def recipeDir = "${rootDir}/infra/recipes/docker-compose/${recipe}"
workingDir recipeDir
commandLine 'docker', 'compose', 'up', '-d'
doFirst {
println ''
println "Starting containers for recipe: ${recipe}"
println ''
}
doLast {
println ''
println '============================================================'
println 'OpenHouse containers started successfully!'
println ''
println 'Services available at:'
println ' Tables Service: http://localhost:8000'
println ' HouseTables Service: http://localhost:8001'
println ' Jobs Service: http://localhost:8002'
println ' Prometheus: http://localhost:9090'
println ' Jaeger UI (traces): http://localhost:16686'
println ''
println 'To stop: ./gradlew dockerDown -Precipe=' + recipe
println '============================================================'
}
}
tasks.register('dockerDown', Exec) {
description = 'Stops and removes Docker containers'
group = 'docker'
def recipe = project.hasProperty('recipe') ? project.property('recipe') : 'oh-hadoop-spark'
def recipeDir = "${rootDir}/infra/recipes/docker-compose/${recipe}"
workingDir recipeDir
commandLine 'docker', 'compose', 'down'
doFirst {
if (!file(recipeDir).exists()) {
throw new GradleException("Recipe directory not found: ${recipeDir}\n" +
"Available recipes: " + file("${rootDir}/infra/recipes/docker-compose")
.listFiles()
.findAll { it.isDirectory() && it.name != 'common' }
.collect { it.name }
.join(', '))
}
println ''
println "Stopping containers for recipe: ${recipe}"
println ''
}
}