-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbuild.gradle.kts
676 lines (589 loc) · 22.2 KB
/
build.gradle.kts
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
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
@file:Suppress("PropertyName")
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import java.net.URI
import java.time.LocalDateTime
import java.time.format.DateTimeFormatter
repositories {
maven {
url = uri("https://plugins.gradle.org/m2/")
}
}
plugins {
java
`java-library`
`java-test-fixtures`
`maven-publish`
// https://github.com/diffplug/spotless
// gradle spotlessApply
id("com.diffplug.spotless").version("6.22.0")
// https://github.com/johnrengelman/shadow
id("com.github.johnrengelman.shadow") version "8.1.1"
// Don't apply for all projects, we individually only apply where Kotlin is used.
kotlin("jvm") version "1.8.21" apply false
// overall code coverage
//jacoco
id("jacoco-report-aggregation")
id("org.sonarqube") version "4.4.1.3373"
}
group = "com.here.naksha"
version = rootProject.properties["version"] as String
val jetbrains_annotations = "org.jetbrains:annotations:24.1.0"
val vertx_version = "4.5.9"
val vertx_core = "io.vertx:vertx-core:$vertx_version"
val vertx_config = "io.vertx:vertx-config:$vertx_version"
val vertx_auth_jwt = "io.vertx:vertx-auth-jwt:$vertx_version"
val vertx_redis_client = "io.vertx:vertx-redis-client:$vertx_version"
val vertx_jdbc_client = "io.vertx:vertx-jdbc-client:$vertx_version"
val vertx_web = "io.vertx:vertx-web:$vertx_version"
val vertx_web_openapi = "io.vertx:vertx-web-openapi:$vertx_version"
val vertx_web_client = "io.vertx:vertx-web-client:$vertx_version"
val vertx_web_templ = "io.vertx:vertx-web-templ-handlebars:$vertx_version"
val netty_transport_native_kqueue = "io.netty:netty-transport-native-kqueue:4.1.112.Final"
val netty_transport_native_epoll = "io.netty:netty-transport-native-epoll:4.1.112.Final"
val jackson_core = "com.fasterxml.jackson.core:jackson-core:2.15.4"
val jackson_core_annotations = "com.fasterxml.jackson.core:jackson-annotations:2.15.4"
val jackson_core_databind = "com.fasterxml.jackson.core:jackson-databind:2.15.4"
val jackson_core_dataformat = "com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.15.4"
var snakeyaml = "org.yaml:snakeyaml:2.2";
val google_flatbuffers = "com.google.flatbuffers:flatbuffers-java:24.3.25"
val google_protobuf = "com.google.protobuf:protobuf-java:4.27.2"
val google_guava = "com.google.guava:guava:33.2.1-jre"
val google_tink = "com.google.crypto.tink:tink:1.14.0"
val aws_bom = "software.amazon.awssdk:bom:2.26.23"
val aws_s3="software.amazon.awssdk:s3"
val jts_core = "org.locationtech.jts:jts-core:1.19.0"
val jts_io = "org.locationtech.jts:jts-io:1.19.0"
val gt_api = "org.geotools:gt-api:19.1"
val gt_referencing = "org.geotools:gt-referencing:19.1"
val gt_epsg_hsql = "org.geotools:gt-epsg-hsql:19.1"
val gt_epsg_extension = "org.geotools:gt-epsg-extension:19.1"
val spatial4j = "com.spatial4j:spatial4j:0.5"
val slf4j_api = "org.slf4j:slf4j-api:2.0.13"
val slf4j_console = "org.slf4j:slf4j-simple:2.0.13";
val jcl_slf4j = "org.slf4j:jcl-over-slf4j:2.0.13"
val log4j_core = "org.apache.logging.log4j:log4j-core:2.23.1"
val log4j_api = "org.apache.logging.log4j:log4j-api:2.23.1"
val log4j_jcl = "org.apache.logging.log4j:log4j-jcl:2.23.1"
val log4j_slf4j = "org.apache.logging.log4j:log4j-slf4j2-impl:2.23.1"
val postgres = "org.postgresql:postgresql:42.7.3"
//val zaxxer_hikari = "com.zaxxer:HikariCP:5.1.0"
val commons_dbutils = "commons-dbutils:commons-dbutils:1.8.1"
val commons_lang3 = "org.apache.commons:commons-lang3:3.15.0"
val jodah_expiringmap = "net.jodah:expiringmap:0.5.11"
val caffinitas_ohc = "org.caffinitas.ohc:ohc-core:0.7.4"
val lmax_disruptor = "com.lmax:disruptor:3.4.4"
val mchange_commons = "com.mchange:mchange-commons-java:0.3.1"
val mchange_c3p0 = "com.mchange:c3p0:0.10.1"
val jayway_jsonpath = "com.jayway.jsonpath:json-path:2.7.0"
val jayway_restassured = "com.jayway.restassured:rest-assured:2.9.0"
val assertj_core = "org.assertj:assertj-core:3.24.2"
val awaitility = "org.awaitility:awaitility:4.2.0"
val junit_jupiter = "org.junit.jupiter:junit-jupiter:5.9.2"
val junit_params = "org.junit.jupiter:junit-jupiter-params:5.9.2"
val mockito = "org.mockito:mockito-core:5.8.0"
val test_containers = "org.testcontainers:testcontainers:1.19.3"
val wiremock = "org.wiremock:wiremock:3.3.1"
val flipkart_zjsonpatch = "com.flipkart.zjsonpatch:zjsonpatch:0.4.16"
val json_assert = "org.skyscreamer:jsonassert:1.5.1"
val resillience4j_retry = "io.github.resilience4j:resilience4j-retry:2.0.0"
val otel = "io.opentelemetry:opentelemetry-api:1.40.0"
val cytodynamics = "com.linkedin.cytodynamics:cytodynamics-nucleus:0.2.0"
val projectRepoURI = getRequiredPropertyFromRootProject("projectRepoURI")
val mavenUrl = getRequiredPropertyFromRootProject("mavenUrl")
val mavenUser = getRequiredPropertyFromRootProject("mavenUser")
val mavenPassword = getRequiredPropertyFromRootProject("mavenPassword")
/*
Overall coverage of subproject - it might be different for different subprojects
Configurable per project - see `setOverallCoverage`
*/
val minOverallCoverageKey: String = "minOverallCoverage"
val defaultOverallMinCoverage: Double = 0.8 // Don't decrease me!
/*
IMPORTANT: api vs implementation
We need to differ between libraries (starting with "here-naksha-lib") and other parts of
the project. For the Naksha libraries we need to select "api" for any dependency, that is
needed for the public API (should be usable by the user of the library), while
“implementation” should be used for all test dependencies, or dependencies that must not be
used by the final users.
*/
// Apply general settings to all sub-projects
subprojects {
// All subprojects should be in the naksha group (for artifactory) and have the same version!
group = rootProject.group
version = rootProject.version
apply(plugin = "java")
apply(plugin = "com.diffplug.spotless")
apply(plugin = "java-library")
apply(plugin = "java-test-fixtures")
apply(plugin = "jacoco")
repositories {
maven(uri("https://repo.osgeo.org/repository/release/"))
mavenCentral()
}
// https://github.com/diffplug/spotless/tree/main/plugin-gradle
spotless {
java {
// excluding tests where Builder pattern gets broken by palantir
targetExclude("src/test/**")
encoding("UTF-8")
// TODO - Disabling auto-correction to 2025 for now. Will handle via separate change.
//val YEAR = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy"))
val YEAR = 2024
licenseHeader("""
/*
* Copyright (C) 2017-$YEAR HERE Europe B.V.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
* License-Filename: LICENSE
*/
""")
// Allow "spotless:off" / "spotless:on" comments to toggle spotless auto-format.
toggleOffOn()
removeUnusedImports()
importOrder()
formatAnnotations()
// https://github.com/diffplug/spotless/issues/1774
palantirJavaFormat("2.39.0")
indentWithTabs(4)
indentWithSpaces(2)
}
}
tasks {
test {
maxHeapSize = "4g"
useJUnitPlatform()
testLogging {
showStandardStreams = true
exceptionFormat = TestExceptionFormat.FULL
events("standardOut", "started", "passed", "skipped", "failed")
}
afterTest(KotlinClosure2(
{ descriptor: TestDescriptor, result: TestResult ->
val totalTime = result.endTime - result.startTime
println("Total time of $descriptor.name was $totalTime")
}
))
}
compileJava {
finalizedBy(spotlessApply)
}
// Suppress Javadoc errors (we document our checked exceptions).
javadoc {
options {
this as StandardJavadocDocletOptions
addBooleanOption("Xdoclint:none", true)
addStringOption("Xmaxwarns", "1")
}
}
jacocoTestReport {
dependsOn(test)
reports {
xml.required = true
}
}
jacocoTestCoverageVerification {
dependsOn(jacocoTestReport)
violationRules {
rule {
limit {
minimum = getOverallCoverage().toBigDecimal()
}
}
}
}
}
java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
// Fix transitive dependencies.
dependencies {
implementation(snakeyaml) {
// https://stackoverflow.com/questions/70154082/getting-java-lang-nosuchmethoderror-org-yaml-snakeyaml-yaml-init-while-runnin
version {
strictly("1.33")
}
}
implementation(platform(aws_bom))
}
// Shared dependencies.
if (name.startsWith("here-naksha-lib")) {
// TODO: We need to expose JTS, but actually we need to upgrade it first.
dependencies {
api(jetbrains_annotations)
api(slf4j_api)
api(jackson_core)
api(jackson_core_databind)
api(jackson_core_dataformat)
api(jackson_core_annotations)
}
} else {
dependencies {
implementation(jetbrains_annotations)
implementation(slf4j_api)
implementation(jackson_core)
implementation(jackson_core_databind)
implementation(jackson_core_dataformat)
implementation(jackson_core_annotations)
}
}
dependencies {
testImplementation(log4j_slf4j)
testImplementation(log4j_api)
testImplementation(log4j_core)
testImplementation(junit_jupiter)
testImplementation(junit_params)
testFixturesApi(junit_jupiter)
}
}
// Note: We normally would want to move these settings into dedicated files in the subprojects,
// but if we do that, the shared section at the end (about publishing and shadow-jar) are
// not that easy AND, worse: We can't share the constants for the dependencies.
project(":here-naksha-lib-core") {
description = "Naksha Core Library"
java {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
withJavadocJar()
withSourcesJar()
}
dependencies {
// Can we get rid of this?
implementation(google_guava)
implementation(commons_lang3)
implementation(jts_core)
implementation(google_flatbuffers)
testImplementation(mockito)
testImplementation(json_assert)
}
setOverallCoverage(0.0) // only increasing allowed!
}
project(":here-naksha-lib-heapcache") {
description = "Naksha Heap Caching Library"
java {
withJavadocJar()
withSourcesJar()
}
dependencies {
api(project(":here-naksha-lib-core"))
testImplementation(mockito)
implementation(jts_core)
}
setOverallCoverage(0.5) // only increasing allowed!
}
project(":here-naksha-lib-psql") {
description = "Naksha PostgresQL Storage Library"
java {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
withJavadocJar()
withSourcesJar()
}
dependencies {
api(project(":here-naksha-lib-core"))
implementation(commons_lang3)
implementation(postgres)
//implementation(zaxxer_hikari)
implementation(commons_dbutils)
implementation(jts_core)
testImplementation(mockito)
testImplementation(spatial4j)
}
setOverallCoverage(0.0) // only increasing allowed!
}
project(":here-naksha-storage-http") {
description = "Naksha Http Storage Module"
java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
withJavadocJar()
withSourcesJar()
}
dependencies {
implementation(project(":here-naksha-lib-core"))
implementation(project(":here-naksha-common-http"))
implementation(commons_lang3)
testImplementation(mockito)
testImplementation("io.rest-assured:rest-assured:5.5.0")
}
tasks.withType<Test> {
if (System.getenv("runConnectorIntegrationTests")?.toBoolean() != true) {
exclude("**/integration/**")
}
}
setOverallCoverage(0.0) // only increasing allowed!
}
project(":here-naksha-lib-view") {
description = "Naksha View Library"
java {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
withJavadocJar()
withSourcesJar()
}
dependencies {
api(project(":here-naksha-lib-core"))
implementation(commons_lang3)
testImplementation(mockito)
testImplementation(project(":here-naksha-lib-psql"))
testImplementation(jts_core)
}
setOverallCoverage(0.0) // only increasing allowed!
}
/*
project(":here-naksha-lib-extension") {
description = "Naksha Extension Library"
dependencies {
api(project(":here-naksha-lib-core"))
}
setOverallCoverage(0.4) // only increasing allowed!
}
*/
project(":here-naksha-handler-activitylog") {
description = "Naksha Activity Log Handler"
dependencies {
implementation(project(":here-naksha-lib-core"))
implementation(project(":here-naksha-lib-psql"))
implementation(project(":here-naksha-lib-handlers"))
implementation(flipkart_zjsonpatch)
testImplementation(jayway_jsonpath)
testImplementation(mockito)
testImplementation(json_assert)
testImplementation(testFixtures(project(":here-naksha-lib-core")))
}
setOverallCoverage(0.4) // only increasing allowed!
}
/*
project(":here-naksha-handler-http") {
description = "Naksha Http Handler"
apply(plugin = "kotlin")
tasks {
// Note: Using compileKotlin {} does not work due to a bug in the Kotlin DSL!
// It only works, when applying the Kotlin plugin for all projects.
withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlinOptions.jvmTarget = JavaVersion.VERSION_17.toString()
finalizedBy(spotlessApply)
}
}
dependencies {
implementation(project(":here-naksha-lib-core"))
testImplementation(project(":here-naksha-lib-extension"))
implementation(jts_core)
testImplementation(jayway_jsonpath)
}
}
*/
configurations.implementation {
exclude(module = "commons-logging")
}
project(":here-naksha-lib-handlers") {
description = "Naksha Handlers library"
dependencies {
implementation(project(":here-naksha-lib-core"))
implementation(project(":here-naksha-lib-psql"))
implementation(project(":here-naksha-lib-view"))
implementation(project(":here-naksha-storage-http"))
implementation(commons_lang3)
implementation(commons_dbutils)
testImplementation(mockito)
testImplementation(json_assert)
testImplementation(testFixtures(project(":here-naksha-lib-core")))
setOverallCoverage(0.0)
}
}
project(":here-naksha-lib-ext-manager") {
description = "Naksha Extension Manager Library"
dependencies {
api(project(":here-naksha-lib-core"))
implementation(aws_s3)
implementation(jcl_slf4j)
implementation(cytodynamics)
testImplementation(mockito)
}
setOverallCoverage(0.0) // only increasing allowed!
}
//try {
project(":here-naksha-lib-hub") {
description = "NakshaHub library"
dependencies {
implementation(project(":here-naksha-lib-core"))
implementation(project(":here-naksha-lib-psql"))
implementation(project(":here-naksha-lib-handlers"))
implementation(project(":here-naksha-lib-ext-manager"))
implementation(commons_lang3)
implementation(jts_core)
implementation(postgres)
implementation(aws_s3)
testImplementation(json_assert)
testImplementation(mockito)
}
setOverallCoverage(0.2) // only increasing allowed!
}
//} catch (ignore: UnknownProjectException) {
//}
//try {
project(":here-naksha-app-service") {
description = "Naksha Service"
dependencies {
implementation(project(":here-naksha-lib-core"))
implementation(project(":here-naksha-lib-psql"))
implementation(project(":here-naksha-storage-http"))
//implementation(project(":here-naksha-lib-extension"))
implementation(project(":here-naksha-lib-hub"))
implementation(project(":here-naksha-common-http"))
implementation(log4j_slf4j)
implementation(log4j_api)
implementation(log4j_core)
implementation(otel)
implementation(commons_lang3)
implementation(jts_core)
implementation(postgres)
implementation(vertx_core)
implementation(vertx_auth_jwt)
implementation(vertx_web)
implementation(vertx_web_client)
implementation(vertx_web_openapi)
implementation(project(":here-naksha-handler-activitylog"))
testImplementation(json_assert)
testImplementation(resillience4j_retry)
testImplementation(test_containers)
testImplementation(testFixtures(project(":here-naksha-lib-core")))
testImplementation(wiremock)
}
setOverallCoverage(0.25) // only increasing allowed!
}
//} catch (ignore: UnknownProjectException) {
//}
subprojects {
apply(plugin = "maven-publish")
publishing {
repositories {
maven {
url = URI(mavenUrl)
credentials.username = mavenUser
credentials.password = mavenPassword
}
}
publications {
create<MavenPublication>("maven") {
groupId = project.group.toString()
artifactId = project.name
version = project.version.toString()
from(components["java"])
pom {
url = "https://${projectRepoURI}"
licenses {
license {
name = "The Apache License, Version 2.0"
url = "http://www.apache.org/licenses/LICENSE-2.0.txt"
}
}
scm {
connection = "scm:git:https://${projectRepoURI}.git"
developerConnection = "scm:git:ssh://git@${projectRepoURI}.git"
url = "https://${projectRepoURI}"
}
}
}
artifacts {
file("build/libs/${project.name}-${project.version}.jar")
file("build/libs/${project.name}-${project.version}-javadoc.jar")
file("build/libs/${project.name}-${project.version}-sources.jar")
}
}
}
}
// For publishing root project (including shaded jar)
publishing {
repositories {
maven {
url = URI(mavenUrl)
credentials.username = mavenUser
credentials.password = mavenPassword
}
}
publications {
create<MavenPublication>("maven") {
groupId = project.group.toString()
artifactId = project.name
version = project.version.toString()
from(components["java"])
pom {
url = "https://${projectRepoURI}"
licenses {
license {
name = "The Apache License, Version 2.0"
url = "http://www.apache.org/licenses/LICENSE-2.0.txt"
}
}
scm {
connection = "scm:git:https://${projectRepoURI}.git"
developerConnection = "scm:git:ssh://git@${projectRepoURI}.git"
url = "https://${projectRepoURI}"
}
}
}
artifacts {
file("build/libs/${project.name}-${project.version}.jar")
file("build/libs/${project.name}-${project.version}-all.jar")
}
}
}
// Create the fat jar for the whole Naksha.
rootProject.dependencies {
//This is needed, otherwise the blank root project will include nothing in the fat jar
implementation(project(":here-naksha-app-service"))
}
// to include license files in Jar
sourceSets {
main {
resources {
setSrcDirs(listOf(".")).setIncludes(listOf("LICENSE","HERE_NOTICE"))
}
}
}
rootProject.tasks.shadowJar {
//Have all tests run before building the fat jar
dependsOn(allprojects.flatMap { it.tasks.withType(Test::class) })
archiveClassifier.set("all")
mergeServiceFiles()
isZip64 = true
manifest {
attributes["Implementation-Title"] = "Naksha Service"
attributes["Main-Class"] = "com.here.naksha.app.service.NakshaApp"
}
}
// print app version
rootProject.tasks.register("printAppVersion") {
println(rootProject.version)
}
fun Project.setOverallCoverage(minOverallCoverage: Double) {
ext.set(minOverallCoverageKey, minOverallCoverage)
}
fun Project.getOverallCoverage(): Double {
return if (ext.has(minOverallCoverageKey)) {
ext.get(minOverallCoverageKey) as? Double
?: throw IllegalStateException("Property '$minOverallCoverageKey' is expected to be Double")
} else {
defaultOverallMinCoverage
}
}
fun getRequiredPropertyFromRootProject(propertyKey: String): String {
return rootProject.properties[propertyKey] as? String ?: throw IllegalArgumentException("""
Not found required property: $propertyKey.
Check your 'gradle.properties' file (in both project and ~/.gradle directory)
""".trimIndent()
)
}