Skip to content

Commit

Permalink
CASL-781 multi module build.gradle.kts configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
cyberhead-pl committed Jan 15, 2025
1 parent 5e611e1 commit d628a3d
Show file tree
Hide file tree
Showing 27 changed files with 742 additions and 693 deletions.
639 changes: 8 additions & 631 deletions build.gradle.kts

Large diffs are not rendered by default.

19 changes: 19 additions & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
plugins {
`kotlin-dsl`
`maven-publish`
}

group = rootProject.group
version = rootProject.version

repositories {
maven("https://plugins.gradle.org/m2/")
}

//apply(plugin = "maven-publish")

dependencies {
implementation("com.diffplug.spotless:spotless-plugin-gradle:6.22.0")
implementation("org.jetbrains.kotlin.multiplatform:org.jetbrains.kotlin.multiplatform.gradle.plugin:2.0.20")
implementation("org.jetbrains.kotlin.plugin.js-plain-objects:org.jetbrains.kotlin.plugin.js-plain-objects.gradle.plugin:2.0.20")
}
17 changes: 17 additions & 0 deletions buildSrc/src/main/kotlin/CodeCoverage.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import org.gradle.api.Project

val minOverallCoverageKey: String = "minOverallCoverage"
val defaultOverallMinCoverage: Double = 0.8 // Don't decrease me!

fun Project.setOverallCoverage(minOverallCoverage: Double) {
this.extensions.extraProperties.set(minOverallCoverageKey, minOverallCoverage)
}

fun Project.getOverallCoverage(): Double {
return if (this.extensions.extraProperties.has(minOverallCoverageKey)) {
this.extensions.extraProperties.get(minOverallCoverageKey) as? Double
?: throw IllegalStateException("Property '$minOverallCoverageKey' is expected to be Double")
} else {
defaultOverallMinCoverage
}
}
91 changes: 91 additions & 0 deletions buildSrc/src/main/kotlin/Dependencies.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
object Lib {

val jetbrains_annotations = "org.jetbrains:annotations:24.0.1"

val vertx_version = "4.5.0"
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.90.Final"
val netty_transport_native_epoll = "io.netty:netty-transport-native-epoll:4.1.90.Final"

val jackson_core = "com.fasterxml.jackson.core:jackson-core:2.15.2"
val jackson_core_annotations = "com.fasterxml.jackson.core:jackson-annotations:2.15.2"
val jackson_core_databind = "com.fasterxml.jackson.core:jackson-databind:2.15.2"
val jackson_core_dataformat = "com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.15.2"
val jackson_kotlin = "com.fasterxml.jackson.module:jackson-module-kotlin:2.15.2"

var snakeyaml = "org.yaml:snakeyaml:1.33";

val google_flatbuffers = "com.google.flatbuffers:flatbuffers-java:23.5.9"
val google_protobuf = "com.google.protobuf:protobuf-java:3.16.3"
val google_guava = "com.google.guava:guava:31.1-jre"
val google_tink = "com.google.crypto.tink:tink:1.5.0"

val aws_bom = "software.amazon.awssdk:bom:2.25.19"
val aws_s3="software.amazon.awssdk:s3"

val jts_core = "org.locationtech.jts:jts-core:1.19.0"
val jts_io_common = "org.locationtech.jts.io:jts-io-common: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 = "org.locationtech.spatial4j:spatial4j:0.8"

val slf4j_api = "org.slf4j:slf4j-api:2.0.6"
val slf4j_console = "org.slf4j:slf4j-simple:2.0.6";
val jcl_slf4j = "org.slf4j:jcl-over-slf4j:2.0.12"


val log4j_core = "org.apache.logging.log4j:log4j-core:2.20.0"
val log4j_api = "org.apache.logging.log4j:log4j-api:2.20.0"
val log4j_jcl = "org.apache.logging.log4j:log4j-jcl:2.20.0"
val log4j_slf4j = "org.apache.logging.log4j:log4j-slf4j2-impl:2.20.0"

val postgres = "org.postgresql:postgresql:42.5.4"
//val zaxxer_hikari = "com.zaxxer:HikariCP:5.1.0"
val commons_dbutils = "commons-dbutils:commons-dbutils:1.7"

val commons_lang3 = "org.apache.commons:commons-lang3:3.12.0"
val jodah_expiringmap = "net.jodah:expiringmap:0.5.10"
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.2.20"
val mchange_c3p0 = "com.mchange:c3p0:0.9.5.5"

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_api = "org.junit.jupiter:junit-jupiter-api:5.9.2"
val junit_jupiter_engine = "org.junit.jupiter:junit-jupiter-engine:5.9.2"
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 mockito_kotlin = "org.mockito.kotlin:mockito-kotlin:5.3.1"
val test_containers = "org.testcontainers:testcontainers:1.19.4"
val test_containers_postgres = "org.testcontainers:postgresql:1.19.4"
val wiremock = "org.wiremock:wiremock:3.3.1"

val flipkart_zjsonpatch = "com.flipkart.zjsonpatch:zjsonpatch:0.4.13"
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.28.0"

val cytodynamics = "com.linkedin.cytodynamics:cytodynamics-nucleus:0.2.0"

val kotlinx_datetime = "org.jetbrains.kotlinx:kotlinx-datetime:0.5.0"
val kotlintest_runner_junit5 = "io.kotlintest:kotlintest-runner-junit5:3.3.2"

val lz4_java = "org.lz4:lz4-java:1.8.0"
}
10 changes: 10 additions & 0 deletions buildSrc/src/main/kotlin/Properties.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import org.gradle.api.Project

fun Project.getRequiredPropertyFromRootProject(propertyKey: String): String {
return this.rootProject.properties[propertyKey] as? String ?: throw IllegalArgumentException(
"""
Not found required property: $propertyKey.
Check your 'gradle.properties' file (in both project and ~/.gradle directory)
""".trimIndent()
)
}
141 changes: 141 additions & 0 deletions buildSrc/src/main/kotlin/naksha.java.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
import org.gradle.api.JavaVersion
import org.gradle.api.tasks.testing.TestDescriptor
import org.gradle.api.tasks.testing.TestResult
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.external.javadoc.StandardJavadocDocletOptions
import org.gradle.kotlin.dsl.*

plugins {
id("java")
id("jacoco-report-aggregation")
id("java-library")
id("java-test-fixtures")
}

group = rootProject.group
version = rootProject.version

repositories {
maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/bootstrap")
maven("https://repo.osgeo.org/repository/release/")
mavenCentral()
}

apply(plugin = "java-library")
apply(plugin = "java-test-fixtures")
apply(plugin = "jacoco")

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")
}
))
}

// 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(Lib.snakeyaml) {
// https://stackoverflow.com/questions/70154082/getting-java-lang-nosuchmethoderror-org-yaml-snakeyaml-yaml-init-while-runnin
version {
strictly("1.33")
}
}
implementation(platform(Lib.aws_bom))
}

// Shared dependencies.
/*
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 users of the library.
*/
if (name.startsWith("here-naksha-lib")) {
// TODO: We need to expose JTS, but actually we need to upgrade it first.
dependencies {
api(Lib.jetbrains_annotations)
api(Lib.slf4j_api)
api(Lib.jackson_core)
api(Lib.jackson_core_databind)
api(Lib.jackson_core_dataformat)
api(Lib.jackson_core_annotations)
}
} else {
dependencies {
implementation(Lib.jetbrains_annotations)
implementation(Lib.slf4j_api)
implementation(Lib.jackson_core)
implementation(Lib.jackson_core_databind)
implementation(Lib.jackson_core_dataformat)
implementation(Lib.jackson_core_annotations)
}
}
dependencies {
testImplementation(Lib.log4j_slf4j)
testImplementation(Lib.log4j_api)
testImplementation(Lib.log4j_core)
testImplementation(Lib.junit_jupiter)
testImplementation(Lib.junit_params)
testFixturesApi(Lib.junit_jupiter)
}

tasks.withType<Jar> {
from(rootProject.file("HERE_NOTICE"))
into("")
}

tasks.withType<Jar> {
from(rootProject.file("LICENSE"))
into("")
}

tasks.register("printAppVersion") {
println(rootProject.version)
}
58 changes: 58 additions & 0 deletions buildSrc/src/main/kotlin/naksha.publish.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import org.gradle.api.publish.maven.MavenPublication
import org.gradle.kotlin.dsl.assign
import org.gradle.kotlin.dsl.create
import org.gradle.kotlin.dsl.get
import org.gradle.kotlin.dsl.`maven-publish`
import java.net.URI

plugins {
id("java")
id("maven-publish")
}

group = "com.here.naksha"
version = rootProject.properties["version"] as String

val projectRepoURI = getRequiredPropertyFromRootProject("projectRepoURI")
val mavenUrl = getRequiredPropertyFromRootProject("mavenUrl")
val mavenUser = getRequiredPropertyFromRootProject("mavenUser")
val mavenPassword = getRequiredPropertyFromRootProject("mavenPassword")

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")
}
}
}
46 changes: 46 additions & 0 deletions buildSrc/src/main/kotlin/naksha.spotless-kotlin.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import org.gradle.kotlin.dsl.apply
import java.time.LocalDateTime
import java.time.format.DateTimeFormatter

plugins {
id("org.jetbrains.kotlin.multiplatform")
id("com.diffplug.spotless")
}

apply(plugin = "com.diffplug.spotless")

// https://github.com/diffplug/spotless/tree/main/plugin-gradle
spotless {

kotlin {
// excluding tests where Builder pattern gets broken by palantir
targetExclude("src/*Test/**")
target("**/*.kt")
encoding("UTF-8")
val YEAR = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy"))
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
*/
""")
}
}

tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
finalizedBy("spotlessApply")
}
Loading

0 comments on commit d628a3d

Please sign in to comment.