Skip to content

Commit ef9f7f9

Browse files
committed
CASL-781 multi module build.gradle.kts configuration
1 parent 5cd9a98 commit ef9f7f9

File tree

27 files changed

+742
-693
lines changed

27 files changed

+742
-693
lines changed

build.gradle.kts

Lines changed: 8 additions & 631 deletions
Large diffs are not rendered by default.

buildSrc/build.gradle.kts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
plugins {
2+
`kotlin-dsl`
3+
`maven-publish`
4+
}
5+
6+
group = rootProject.group
7+
version = rootProject.version
8+
9+
repositories {
10+
maven("https://plugins.gradle.org/m2/")
11+
}
12+
13+
//apply(plugin = "maven-publish")
14+
15+
dependencies {
16+
implementation("com.diffplug.spotless:spotless-plugin-gradle:6.22.0")
17+
implementation("org.jetbrains.kotlin.multiplatform:org.jetbrains.kotlin.multiplatform.gradle.plugin:2.0.20")
18+
implementation("org.jetbrains.kotlin.plugin.js-plain-objects:org.jetbrains.kotlin.plugin.js-plain-objects.gradle.plugin:2.0.20")
19+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import org.gradle.api.Project
2+
3+
val minOverallCoverageKey: String = "minOverallCoverage"
4+
val defaultOverallMinCoverage: Double = 0.8 // Don't decrease me!
5+
6+
fun Project.setOverallCoverage(minOverallCoverage: Double) {
7+
this.extensions.extraProperties.set(minOverallCoverageKey, minOverallCoverage)
8+
}
9+
10+
fun Project.getOverallCoverage(): Double {
11+
return if (this.extensions.extraProperties.has(minOverallCoverageKey)) {
12+
this.extensions.extraProperties.get(minOverallCoverageKey) as? Double
13+
?: throw IllegalStateException("Property '$minOverallCoverageKey' is expected to be Double")
14+
} else {
15+
defaultOverallMinCoverage
16+
}
17+
}
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
object Lib {
2+
3+
val jetbrains_annotations = "org.jetbrains:annotations:24.0.1"
4+
5+
val vertx_version = "4.5.0"
6+
val vertx_core = "io.vertx:vertx-core:$vertx_version"
7+
val vertx_config = "io.vertx:vertx-config:$vertx_version"
8+
val vertx_auth_jwt = "io.vertx:vertx-auth-jwt:$vertx_version"
9+
val vertx_redis_client = "io.vertx:vertx-redis-client:$vertx_version"
10+
val vertx_jdbc_client = "io.vertx:vertx-jdbc-client:$vertx_version"
11+
val vertx_web = "io.vertx:vertx-web:$vertx_version"
12+
val vertx_web_openapi = "io.vertx:vertx-web-openapi:$vertx_version"
13+
val vertx_web_client = "io.vertx:vertx-web-client:$vertx_version"
14+
val vertx_web_templ = "io.vertx:vertx-web-templ-handlebars:$vertx_version"
15+
16+
val netty_transport_native_kqueue = "io.netty:netty-transport-native-kqueue:4.1.90.Final"
17+
val netty_transport_native_epoll = "io.netty:netty-transport-native-epoll:4.1.90.Final"
18+
19+
val jackson_core = "com.fasterxml.jackson.core:jackson-core:2.15.2"
20+
val jackson_core_annotations = "com.fasterxml.jackson.core:jackson-annotations:2.15.2"
21+
val jackson_core_databind = "com.fasterxml.jackson.core:jackson-databind:2.15.2"
22+
val jackson_core_dataformat = "com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.15.2"
23+
val jackson_kotlin = "com.fasterxml.jackson.module:jackson-module-kotlin:2.15.2"
24+
25+
var snakeyaml = "org.yaml:snakeyaml:1.33";
26+
27+
val google_flatbuffers = "com.google.flatbuffers:flatbuffers-java:23.5.9"
28+
val google_protobuf = "com.google.protobuf:protobuf-java:3.16.3"
29+
val google_guava = "com.google.guava:guava:31.1-jre"
30+
val google_tink = "com.google.crypto.tink:tink:1.5.0"
31+
32+
val aws_bom = "software.amazon.awssdk:bom:2.25.19"
33+
val aws_s3="software.amazon.awssdk:s3"
34+
35+
val jts_core = "org.locationtech.jts:jts-core:1.19.0"
36+
val jts_io_common = "org.locationtech.jts.io:jts-io-common:1.19.0"
37+
val gt_api = "org.geotools:gt-api:19.1"
38+
val gt_referencing = "org.geotools:gt-referencing:19.1"
39+
val gt_epsg_hsql = "org.geotools:gt-epsg-hsql:19.1"
40+
val gt_epsg_extension = "org.geotools:gt-epsg-extension:19.1"
41+
42+
val spatial4j = "org.locationtech.spatial4j:spatial4j:0.8"
43+
44+
val slf4j_api = "org.slf4j:slf4j-api:2.0.6"
45+
val slf4j_console = "org.slf4j:slf4j-simple:2.0.6";
46+
val jcl_slf4j = "org.slf4j:jcl-over-slf4j:2.0.12"
47+
48+
49+
val log4j_core = "org.apache.logging.log4j:log4j-core:2.20.0"
50+
val log4j_api = "org.apache.logging.log4j:log4j-api:2.20.0"
51+
val log4j_jcl = "org.apache.logging.log4j:log4j-jcl:2.20.0"
52+
val log4j_slf4j = "org.apache.logging.log4j:log4j-slf4j2-impl:2.20.0"
53+
54+
val postgres = "org.postgresql:postgresql:42.5.4"
55+
//val zaxxer_hikari = "com.zaxxer:HikariCP:5.1.0"
56+
val commons_dbutils = "commons-dbutils:commons-dbutils:1.7"
57+
58+
val commons_lang3 = "org.apache.commons:commons-lang3:3.12.0"
59+
val jodah_expiringmap = "net.jodah:expiringmap:0.5.10"
60+
val caffinitas_ohc = "org.caffinitas.ohc:ohc-core:0.7.4"
61+
val lmax_disruptor = "com.lmax:disruptor:3.4.4"
62+
val mchange_commons = "com.mchange:mchange-commons-java:0.2.20"
63+
val mchange_c3p0 = "com.mchange:c3p0:0.9.5.5"
64+
65+
val jayway_jsonpath = "com.jayway.jsonpath:json-path:2.7.0"
66+
val jayway_restassured = "com.jayway.restassured:rest-assured:2.9.0"
67+
val assertj_core = "org.assertj:assertj-core:3.24.2"
68+
val awaitility = "org.awaitility:awaitility:4.2.0"
69+
val junit_jupiter_api = "org.junit.jupiter:junit-jupiter-api:5.9.2"
70+
val junit_jupiter_engine = "org.junit.jupiter:junit-jupiter-engine:5.9.2"
71+
val junit_jupiter = "org.junit.jupiter:junit-jupiter:5.9.2"
72+
val junit_params = "org.junit.jupiter:junit-jupiter-params:5.9.2"
73+
val mockito = "org.mockito:mockito-core:5.8.0"
74+
val mockito_kotlin = "org.mockito.kotlin:mockito-kotlin:5.3.1"
75+
val test_containers = "org.testcontainers:testcontainers:1.19.4"
76+
val test_containers_postgres = "org.testcontainers:postgresql:1.19.4"
77+
val wiremock = "org.wiremock:wiremock:3.3.1"
78+
79+
val flipkart_zjsonpatch = "com.flipkart.zjsonpatch:zjsonpatch:0.4.13"
80+
val json_assert = "org.skyscreamer:jsonassert:1.5.1"
81+
val resillience4j_retry = "io.github.resilience4j:resilience4j-retry:2.0.0"
82+
83+
val otel = "io.opentelemetry:opentelemetry-api:1.28.0"
84+
85+
val cytodynamics = "com.linkedin.cytodynamics:cytodynamics-nucleus:0.2.0"
86+
87+
val kotlinx_datetime = "org.jetbrains.kotlinx:kotlinx-datetime:0.5.0"
88+
val kotlintest_runner_junit5 = "io.kotlintest:kotlintest-runner-junit5:3.3.2"
89+
90+
val lz4_java = "org.lz4:lz4-java:1.8.0"
91+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import org.gradle.api.Project
2+
3+
fun Project.getRequiredPropertyFromRootProject(propertyKey: String): String {
4+
return this.rootProject.properties[propertyKey] as? String ?: throw IllegalArgumentException(
5+
"""
6+
Not found required property: $propertyKey.
7+
Check your 'gradle.properties' file (in both project and ~/.gradle directory)
8+
""".trimIndent()
9+
)
10+
}
Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
import org.gradle.api.JavaVersion
2+
import org.gradle.api.tasks.testing.TestDescriptor
3+
import org.gradle.api.tasks.testing.TestResult
4+
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
5+
import org.gradle.external.javadoc.StandardJavadocDocletOptions
6+
import org.gradle.kotlin.dsl.*
7+
8+
plugins {
9+
id("java")
10+
id("jacoco-report-aggregation")
11+
id("java-library")
12+
id("java-test-fixtures")
13+
}
14+
15+
group = rootProject.group
16+
version = rootProject.version
17+
18+
repositories {
19+
maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/bootstrap")
20+
maven("https://repo.osgeo.org/repository/release/")
21+
mavenCentral()
22+
}
23+
24+
apply(plugin = "java-library")
25+
apply(plugin = "java-test-fixtures")
26+
apply(plugin = "jacoco")
27+
28+
tasks {
29+
test {
30+
maxHeapSize = "4g"
31+
useJUnitPlatform()
32+
testLogging {
33+
showStandardStreams = true
34+
exceptionFormat = TestExceptionFormat.FULL
35+
events("standardOut", "started", "passed", "skipped", "failed")
36+
}
37+
afterTest(KotlinClosure2(
38+
{ descriptor: TestDescriptor, result: TestResult ->
39+
val totalTime = result.endTime - result.startTime
40+
println("Total time of $descriptor.name was $totalTime")
41+
}
42+
))
43+
}
44+
45+
// Suppress Javadoc errors (we document our checked exceptions).
46+
javadoc {
47+
options {
48+
this as StandardJavadocDocletOptions
49+
addBooleanOption("Xdoclint:none", true)
50+
addStringOption("Xmaxwarns", "1")
51+
}
52+
}
53+
54+
jacocoTestReport {
55+
dependsOn(test)
56+
reports {
57+
xml.required = true
58+
}
59+
}
60+
61+
jacocoTestCoverageVerification {
62+
dependsOn(jacocoTestReport)
63+
violationRules {
64+
rule {
65+
limit {
66+
minimum = getOverallCoverage().toBigDecimal()
67+
}
68+
}
69+
}
70+
}
71+
}
72+
73+
java {
74+
sourceCompatibility = JavaVersion.VERSION_17
75+
targetCompatibility = JavaVersion.VERSION_17
76+
}
77+
78+
// Fix transitive dependencies.
79+
80+
dependencies {
81+
implementation(Lib.snakeyaml) {
82+
// https://stackoverflow.com/questions/70154082/getting-java-lang-nosuchmethoderror-org-yaml-snakeyaml-yaml-init-while-runnin
83+
version {
84+
strictly("1.33")
85+
}
86+
}
87+
implementation(platform(Lib.aws_bom))
88+
}
89+
90+
// Shared dependencies.
91+
/*
92+
IMPORTANT: api vs implementation
93+
94+
We need to differ between libraries (starting with "here-naksha-lib") and other parts of
95+
the project. For the Naksha libraries we need to select "api" for any dependency, that is
96+
needed for the public API (should be usable by the user of the library), while
97+
“implementation” should be used for all test dependencies, or dependencies that must not be
98+
used by the users of the library.
99+
*/
100+
if (name.startsWith("here-naksha-lib")) {
101+
// TODO: We need to expose JTS, but actually we need to upgrade it first.
102+
dependencies {
103+
api(Lib.jetbrains_annotations)
104+
api(Lib.slf4j_api)
105+
api(Lib.jackson_core)
106+
api(Lib.jackson_core_databind)
107+
api(Lib.jackson_core_dataformat)
108+
api(Lib.jackson_core_annotations)
109+
}
110+
} else {
111+
dependencies {
112+
implementation(Lib.jetbrains_annotations)
113+
implementation(Lib.slf4j_api)
114+
implementation(Lib.jackson_core)
115+
implementation(Lib.jackson_core_databind)
116+
implementation(Lib.jackson_core_dataformat)
117+
implementation(Lib.jackson_core_annotations)
118+
}
119+
}
120+
dependencies {
121+
testImplementation(Lib.log4j_slf4j)
122+
testImplementation(Lib.log4j_api)
123+
testImplementation(Lib.log4j_core)
124+
testImplementation(Lib.junit_jupiter)
125+
testImplementation(Lib.junit_params)
126+
testFixturesApi(Lib.junit_jupiter)
127+
}
128+
129+
tasks.withType<Jar> {
130+
from(rootProject.file("HERE_NOTICE"))
131+
into("")
132+
}
133+
134+
tasks.withType<Jar> {
135+
from(rootProject.file("LICENSE"))
136+
into("")
137+
}
138+
139+
tasks.register("printAppVersion") {
140+
println(rootProject.version)
141+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import org.gradle.api.publish.maven.MavenPublication
2+
import org.gradle.kotlin.dsl.assign
3+
import org.gradle.kotlin.dsl.create
4+
import org.gradle.kotlin.dsl.get
5+
import org.gradle.kotlin.dsl.`maven-publish`
6+
import java.net.URI
7+
8+
plugins {
9+
id("java")
10+
id("maven-publish")
11+
}
12+
13+
group = "com.here.naksha"
14+
version = rootProject.properties["version"] as String
15+
16+
val projectRepoURI = getRequiredPropertyFromRootProject("projectRepoURI")
17+
val mavenUrl = getRequiredPropertyFromRootProject("mavenUrl")
18+
val mavenUser = getRequiredPropertyFromRootProject("mavenUser")
19+
val mavenPassword = getRequiredPropertyFromRootProject("mavenPassword")
20+
21+
publishing {
22+
repositories {
23+
maven {
24+
url = URI(mavenUrl)
25+
credentials.username = mavenUser
26+
credentials.password = mavenPassword
27+
}
28+
}
29+
30+
publications {
31+
create<MavenPublication>("maven") {
32+
groupId = project.group.toString()
33+
artifactId = project.name
34+
version = project.version.toString()
35+
from(components["java"])
36+
pom {
37+
url = "https://${projectRepoURI}"
38+
licenses {
39+
license {
40+
name = "The Apache License, Version 2.0"
41+
url = "http://www.apache.org/licenses/LICENSE-2.0.txt"
42+
}
43+
}
44+
scm {
45+
connection = "scm:git:https://${projectRepoURI}.git"
46+
developerConnection = "scm:git:ssh://git@${projectRepoURI}.git"
47+
url = "https://${projectRepoURI}"
48+
}
49+
}
50+
}
51+
52+
artifacts {
53+
file("build/libs/${project.name}-${project.version}.jar")
54+
file("build/libs/${project.name}-${project.version}-javadoc.jar")
55+
file("build/libs/${project.name}-${project.version}-sources.jar")
56+
}
57+
}
58+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import org.gradle.kotlin.dsl.apply
2+
import java.time.LocalDateTime
3+
import java.time.format.DateTimeFormatter
4+
5+
plugins {
6+
id("org.jetbrains.kotlin.multiplatform")
7+
id("com.diffplug.spotless")
8+
}
9+
10+
apply(plugin = "com.diffplug.spotless")
11+
12+
// https://github.com/diffplug/spotless/tree/main/plugin-gradle
13+
spotless {
14+
15+
kotlin {
16+
// excluding tests where Builder pattern gets broken by palantir
17+
targetExclude("src/*Test/**")
18+
target("**/*.kt")
19+
encoding("UTF-8")
20+
val YEAR = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy"))
21+
licenseHeader("""
22+
/*
23+
* Copyright (C) 2017-$YEAR HERE Europe B.V.
24+
*
25+
* Licensed under the Apache License, Version 2.0 (the "License");
26+
* you may not use this file except in compliance with the License.
27+
* You may obtain a copy of the License at
28+
*
29+
* http://www.apache.org/licenses/LICENSE-2.0
30+
*
31+
* Unless required by applicable law or agreed to in writing, software
32+
* distributed under the License is distributed on an "AS IS" BASIS,
33+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
34+
* See the License for the specific language governing permissions and
35+
* limitations under the License.
36+
*
37+
* SPDX-License-Identifier: Apache-2.0
38+
* License-Filename: LICENSE
39+
*/
40+
""")
41+
}
42+
}
43+
44+
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
45+
finalizedBy("spotlessApply")
46+
}

0 commit comments

Comments
 (0)