From 2ed26330eb04c010203c0856b2f8ee2a73462657 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Sch=C3=A4ffner?= Date: Mon, 14 Oct 2024 23:27:18 +0200 Subject: [PATCH] upgrade to java 21, use gradle version catalogue --- Dockerfile | 2 +- app/build.gradle.kts | 28 ++++++------ build.gradle.kts | 39 ++++++++--------- domain/build.gradle.kts | 25 +++++------ frontend/build.gradle.kts | 3 +- gradle/libs.versions.toml | 83 ++++++++++++++++++++++++++++++++++++ logging/build.gradle.kts | 4 +- persistence/build.gradle.kts | 32 +++++++------- web/build.gradle.kts | 55 ++++++++++++------------ 9 files changed, 178 insertions(+), 93 deletions(-) create mode 100644 gradle/libs.versions.toml diff --git a/Dockerfile b/Dockerfile index 328afd8d..e8320251 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ # syntax=docker/dockerfile:1 -FROM gcr.io/distroless/java17-debian11 +FROM gcr.io/distroless/java21-debian12 WORKDIR /app COPY app/build/libs/app-*-all.jar ./app.jar CMD ["app.jar"] diff --git a/app/build.gradle.kts b/app/build.gradle.kts index ea8c247b..8b6b9782 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -1,7 +1,7 @@ plugins { - kotlin("jvm") + alias(libs.plugins.kotlin.jvm) application - id("com.github.johnrengelman.shadow") version "8.1.1" + alias(libs.plugins.shadow) } application { @@ -22,17 +22,19 @@ dependencies { implementation(project(":domain")) implementation(project(":persistence")) implementation(project(":logging")) - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.9.0") - implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.6.1") + implementation(rootProject.libs.kotlinx.coroutines.core) + implementation(rootProject.libs.kotlinx.datetime) testImplementation(testFixtures(project(":domain"))) - testImplementation("io.ktor:ktor-serialization:2.3.12") - testImplementation("io.ktor:ktor-server-test-host:2.3.12") - testImplementation("io.ktor:ktor-client-content-negotiation:2.3.12") - testImplementation("io.ktor:ktor-serialization-kotlinx-json:2.3.12") - testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.9.0") - testImplementation("org.testcontainers:testcontainers:1.20.2") - testImplementation("org.testcontainers:postgresql:1.20.2") - testImplementation("org.jetbrains.exposed:exposed-core:0.55.0") - testImplementation("com.zaxxer:HikariCP:6.0.0") + // TODO REMOVE + // testImplementation(rootProject.libs.ktor.serialization) + testImplementation(rootProject.libs.ktor.server.test.host) + testImplementation(rootProject.libs.ktor.client.content.negotiation) + testImplementation(rootProject.libs.ktor.serialization.kotlinx.json) + testImplementation(rootProject.libs.wiremock) + testImplementation(rootProject.libs.kotlinx.coroutines.test) + testImplementation(rootProject.libs.testcontainers) + testImplementation(rootProject.libs.testcontainers.postgres) + testImplementation(rootProject.libs.exposed.core) + testImplementation(rootProject.libs.hikaricp) } diff --git a/build.gradle.kts b/build.gradle.kts index 59279d25..3a42fa92 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -2,9 +2,9 @@ import org.gradle.api.tasks.testing.logging.TestLogEvent plugins { base - kotlin("jvm") version "2.0.20" + alias(libs.plugins.kotlin.jvm) jacoco - id("com.github.ben-manes.versions") version "0.51.0" + alias(libs.plugins.versions) } tasks.register("stage") { @@ -21,15 +21,11 @@ allprojects { repositories { mavenCentral() maven("https://oss.sonatype.org/content/repositories/snapshots/") - maven { - url = uri("https://maven.pkg.jetbrains.space/public/p/ktor/eap") - } } - tasks.withType().configureEach { - kotlinOptions { - jvmTarget = "17" - freeCompilerArgs += "-opt-in=kotlin.RequiresOptIn" + java { + toolchain { + languageVersion = JavaLanguageVersion.of(21) } } @@ -52,19 +48,18 @@ allprojects { } dependencies { - implementation(enforcedPlatform("org.jetbrains.kotlin:kotlin-bom:2.0.20")) - implementation("org.jetbrains.kotlin:kotlin-stdlib") - implementation("io.arrow-kt:arrow-core:1.2.4") - implementation("org.kodein.di:kodein-di:7.22.0") - implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.6.1") - implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.3") + implementation(rootProject.libs.kotlin.stdlib) + implementation(rootProject.libs.arrow.core) + implementation(rootProject.libs.kodein) + implementation(rootProject.libs.kotlinx.datetime) + implementation(rootProject.libs.kotlinx.serialization.json) - testImplementation("org.jetbrains.kotlin:kotlin-test") - testImplementation("org.jetbrains.kotlin:kotlin-test-junit5") - testImplementation("org.junit.jupiter:junit-jupiter-engine:5.11.1") - testImplementation("org.junit.jupiter:junit-jupiter-params:5.11.1") - testImplementation("com.willowtreeapps.assertk:assertk-jvm:0.28.1") - testImplementation("org.mockito.kotlin:mockito-kotlin:5.4.0") - testImplementation("org.mockito:mockito-junit-jupiter:5.14.1") + testImplementation(rootProject.libs.kotlin.test) + testImplementation(rootProject.libs.kotlin.test.junit5) + testImplementation(rootProject.libs.junit.engine) + testImplementation(rootProject.libs.junit.params) + testImplementation(rootProject.libs.assertk.jvm) + testImplementation(rootProject.libs.mockito.kotlin) + testImplementation(rootProject.libs.mockito.junit5) } } diff --git a/domain/build.gradle.kts b/domain/build.gradle.kts index d887009b..62432d0f 100644 --- a/domain/build.gradle.kts +++ b/domain/build.gradle.kts @@ -1,21 +1,22 @@ plugins { - kotlin("jvm") + alias(libs.plugins.kotlin.jvm) `java-test-fixtures` - kotlin("plugin.serialization") version "2.0.20" + alias(libs.plugins.kotlinx.serialization) } dependencies { - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.9.0") - implementation("com.webauthn4j:webauthn4j-core:0.26.0.RELEASE") - implementation("com.sksamuel.scrimage:scrimage-core:4.2.0") + implementation(rootProject.libs.kotlinx.coroutines.core) + implementation(rootProject.libs.webauthn4j.core) + implementation(rootProject.libs.scrimage.core) - testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.9.0") - testFixturesImplementation("com.webauthn4j:webauthn4j-core:0.26.0.RELEASE") - testFixturesImplementation("org.jetbrains.kotlinx:kotlinx-datetime:0.6.1") - testFixturesImplementation("io.arrow-kt:arrow-core:1.2.4") - testFixturesImplementation("com.willowtreeapps.assertk:assertk-jvm:0.28.1") - testFixturesImplementation("org.mockito.kotlin:mockito-kotlin:5.4.0") - testFixturesImplementation("org.mockito:mockito-junit-jupiter:5.14.1") + testImplementation(rootProject.libs.kotlinx.coroutines.test) + + testFixturesImplementation(rootProject.libs.webauthn4j.core) + testFixturesImplementation(rootProject.libs.kotlinx.datetime) + testFixturesImplementation(rootProject.libs.arrow.core) + testFixturesImplementation(rootProject.libs.assertk.jvm) + testFixturesImplementation(rootProject.libs.mockito.kotlin) + testFixturesImplementation(rootProject.libs.mockito.junit5) } kotlin.target.compilations.getByName("testFixtures") { diff --git a/frontend/build.gradle.kts b/frontend/build.gradle.kts index d483e8b3..533fa04f 100644 --- a/frontend/build.gradle.kts +++ b/frontend/build.gradle.kts @@ -1,6 +1,7 @@ plugins { java - id("com.github.node-gradle.node") version "7.1.0" + alias(libs.plugins.node) + alias(libs.plugins.kotlinx.serialization) } node { diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml new file mode 100644 index 00000000..dc7a359d --- /dev/null +++ b/gradle/libs.versions.toml @@ -0,0 +1,83 @@ +[versions] +kotlin = "2.0.20" +arrow = "1.2.4" +kodein = "7.22.0" +ktor = "2.3.12" +micrometer = "1.13.4" +kotlinx-coroutines = "1.9.0" +kotlinx-datetime = "0.6.1" +kotlinx-serialization-json = "1.7.3" +exposed = "0.55.0" +hikari = "6.0.0" +postgresql = "42.7.4" +liquibase = "4.29.2" +liquibase-slf4j = "5.0.0" +webauthn4j = "0.26.0.RELEASE" +scrimage = "4.2.0" +logback = "1.5.8" +slf4j = "2.0.16" + +junit = "5.11.1" +assertk = "0.28.1" +mockito-kotlin = "5.4.0" +mockito-junit5 = "5.14.0" +kotlin-wiremock = "2.1.1" +testcontainers = "1.20.2" + +[libraries] +kotlin-stdlib = { module = "org.jetbrains.kotlin:kotlin-stdlib", version.ref = "kotlin" } +arrow-core = { module = "io.arrow-kt:arrow-core", version.ref = "arrow" } +kodein = { module = "org.kodein.di:kodein-di", version.ref = "kodein" } +ktor-server-core = { module = "io.ktor:ktor-server-core", version.ref = "ktor" } +ktor-server-core-jvm = { module = "io.ktor:ktor-server-core-jvm", version.ref = "ktor" } +ktor-server-netty = { module = "io.ktor:ktor-server-netty", version.ref = "ktor" } +ktor-server-auth = { module = "io.ktor:ktor-server-auth", version.ref = "ktor" } +ktor-server-auth-jwt = { module = "io.ktor:ktor-server-auth-jwt", version.ref = "ktor" } +ktor-server-forwarded-header = { module = "io.ktor:ktor-server-forwarded-header", version.ref = "ktor" } +ktor-server-content-negotiation = { module = "io.ktor:ktor-server-content-negotiation", version.ref = "ktor" } +ktor-serialization-kotlinx-json = { module = "io.ktor:ktor-serialization-kotlinx-json", version.ref = "ktor" } +ktor-server-cors = { module = "io.ktor:ktor-server-cors", version.ref = "ktor" } +ktor-server-call-logging = { module = "io.ktor:ktor-server-call-logging", version.ref = "ktor" } +ktor-server-http-redirect = { module = "io.ktor:ktor-server-http-redirect", version.ref = "ktor" } +ktor-server-status-pages = { module = "io.ktor:ktor-server-status-pages", version.ref = "ktor" } +ktor-server-websockets = { module = "io.ktor:ktor-server-websockets", version.ref = "ktor" } +ktor-server-metrics-micrometer = { module = "io.ktor:ktor-server-metrics-micrometer", version.ref = "ktor" } +ktor-server-metrics-micrometer-jvm = { module = "io.ktor:ktor-server-metrics-micrometer-jvm", version.ref = "ktor" } +micrometer-registry-prometheus = { module = "io.micrometer:micrometer-registry-prometheus", version.ref = "micrometer" } + +kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlinx-coroutines" } +kotlinx-datetime = { module = "org.jetbrains.kotlinx:kotlinx-datetime", version.ref = "kotlinx-datetime" } +kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kotlinx-serialization-json" } +exposed-core = { module = "org.jetbrains.exposed:exposed-core", version.ref = "exposed" } +exposed-json = { module = "org.jetbrains.exposed:exposed-json", version.ref = "exposed" } +exposed-jdbc = { module = "org.jetbrains.exposed:exposed-jdbc", version.ref = "exposed" } +exposed-java-time = { module = "org.jetbrains.exposed:exposed-java-time", version.ref = "exposed" } +hikaricp = { module = "com.zaxxer:HikariCP", version.ref = "hikari" } +postgresql = { module = "org.postgresql:postgresql", version.ref = "postgresql" } +liquibase = { module = "org.liquibase:liquibase-core", version.ref = "liquibase" } +liquibase-slf4j = { module = "com.mattbertolini:liquibase-slf4j", version.ref = "liquibase-slf4j" } +webauthn4j-core = { module = "com.webauthn4j:webauthn4j-core", version.ref = "webauthn4j" } +scrimage-core = { module = "com.sksamuel.scrimage:scrimage-core", version.ref = "scrimage" } +logback = { module = "ch.qos.logback:logback-classic", version.ref = "logback" } +slf4j-api = { module = "org.slf4j:slf4j-api", version.ref = "slf4j" } + +kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin" } +kotlin-test-junit5 = { module = "org.jetbrains.kotlin:kotlin-test-junit5", version.ref = "kotlin" } +kotlinx-coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "kotlinx-coroutines" } +junit-engine = { module = "org.junit.jupiter:junit-jupiter-engine", version.ref = "junit" } +junit-params = { module = "org.junit.jupiter:junit-jupiter-params", version.ref = "junit" } +assertk-jvm = { module = "com.willowtreeapps.assertk:assertk-jvm", version.ref = "assertk" } +mockito-kotlin = { module = "org.mockito.kotlin:mockito-kotlin", version.ref = "mockito-kotlin" } +mockito-junit5 = { module = "org.mockito:mockito-junit-jupiter", version.ref = "mockito-junit5" } +ktor-server-test-host = { module = "io.ktor:ktor-server-test-host", version.ref = "ktor" } +ktor-client-content-negotiation = { module = "io.ktor:ktor-client-content-negotiation", version.ref = "ktor" } +wiremock = { module = "com.marcinziolo:kotlin-wiremock", version.ref="kotlin-wiremock" } +testcontainers = { module = "org.testcontainers:testcontainers", version.ref = "testcontainers" } +testcontainers-postgres = { module = "org.testcontainers:postgresql", version.ref = "testcontainers" } + +[plugins] +kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } +kotlinx-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" } +shadow = { id = "com.github.johnrengelman.shadow", version = "8.1.1" } +versions = { id = "com.github.ben-manes.versions", version = "0.51.0" } +node = { id = "com.github.node-gradle.node", version = "7.1.0" } diff --git a/logging/build.gradle.kts b/logging/build.gradle.kts index 4d3368cd..cf8a11f7 100644 --- a/logging/build.gradle.kts +++ b/logging/build.gradle.kts @@ -1,9 +1,9 @@ plugins { - kotlin("jvm") + alias(libs.plugins.kotlin.jvm) } dependencies { implementation(project(":domain")) - implementation("ch.qos.logback:logback-classic:1.5.8") + implementation(rootProject.libs.logback) } diff --git a/persistence/build.gradle.kts b/persistence/build.gradle.kts index 847d2c76..43633963 100644 --- a/persistence/build.gradle.kts +++ b/persistence/build.gradle.kts @@ -1,23 +1,25 @@ plugins { - kotlin("jvm") - kotlin("plugin.serialization") version "2.0.20" + alias(libs.plugins.kotlin.jvm) + alias(libs.plugins.kotlinx.serialization) } dependencies { implementation(project(":domain")) implementation(project(":logging")) - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.9.0") - implementation("org.jetbrains.exposed:exposed-core:0.55.0") - implementation("org.jetbrains.exposed:exposed-json:0.55.0") - implementation("org.jetbrains.exposed:exposed-jdbc:0.55.0") - implementation("org.jetbrains.exposed:exposed-java-time:0.55.0") - implementation("com.zaxxer:HikariCP:6.0.0") - implementation("org.postgresql:postgresql:42.7.4") - implementation("org.liquibase:liquibase-core:4.29.2") - implementation("com.mattbertolini:liquibase-slf4j:5.0.0") + implementation(rootProject.libs.kotlinx.coroutines.core) + implementation(rootProject.libs.exposed.core) + implementation(rootProject.libs.exposed.json) + implementation(rootProject.libs.exposed.jdbc) + implementation(rootProject.libs.exposed.java.time) + implementation(rootProject.libs.hikaricp) + implementation(rootProject.libs.postgresql) + implementation(rootProject.libs.liquibase) + implementation(rootProject.libs.liquibase.slf4j) + implementation(rootProject.libs.kotlinx.coroutines.test) + testImplementation(testFixtures(project(":domain"))) - testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.9.0") - testImplementation("org.testcontainers:testcontainers:1.20.2") - testImplementation("org.testcontainers:postgresql:1.20.2") -} + testImplementation(rootProject.libs.kotlinx.coroutines.test) + testImplementation(rootProject.libs.testcontainers) + testImplementation(rootProject.libs.testcontainers.postgres) +} \ No newline at end of file diff --git a/web/build.gradle.kts b/web/build.gradle.kts index 4023a5ca..ff3db355 100644 --- a/web/build.gradle.kts +++ b/web/build.gradle.kts @@ -1,37 +1,38 @@ plugins { - kotlin("jvm") - kotlin("plugin.serialization") version "2.0.20" + alias(libs.plugins.kotlin.jvm) + alias(libs.plugins.kotlinx.serialization) } dependencies { implementation(project(":domain")) implementation(project(":logging")) - implementation("io.ktor:ktor-server-core:2.3.12") - implementation("io.ktor:ktor-server-core-jvm:2.3.12") - implementation("io.ktor:ktor-server-netty:2.3.12") - implementation("io.ktor:ktor-server-auth:2.3.12") - implementation("io.ktor:ktor-server-auth-jwt:2.3.12") - implementation("io.ktor:ktor-server-http-redirect:2.3.12") - implementation("io.ktor:ktor-server-forwarded-header:2.3.12") - implementation("io.ktor:ktor-server-content-negotiation:2.3.12") - implementation("io.ktor:ktor-serialization-kotlinx-json:2.3.12") - implementation("io.ktor:ktor-server-cors:2.3.12") - implementation("io.ktor:ktor-server-status-pages:2.3.12") - implementation("io.ktor:ktor-server-websockets:2.3.12") - implementation("io.ktor:ktor-server-call-logging:2.3.12") - implementation("io.ktor:ktor-server-metrics-micrometer:2.3.12") - implementation("io.ktor:ktor-server-metrics-micrometer-jvm:2.3.12") - implementation("io.micrometer:micrometer-registry-prometheus:1.13.4") - implementation("org.slf4j:slf4j-api:2.0.16") - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.9.0") - implementation("ch.qos.logback:logback-classic:1.5.8") - implementation("com.webauthn4j:webauthn4j-core:0.26.0.RELEASE") + implementation(rootProject.libs.ktor.server.core) + implementation(rootProject.libs.ktor.server.core.jvm) + implementation(rootProject.libs.ktor.server.netty) + implementation(rootProject.libs.ktor.server.auth) + implementation(rootProject.libs.ktor.server.auth.jwt) + implementation(rootProject.libs.ktor.server.http.redirect) + implementation(rootProject.libs.ktor.server.forwarded.header) + implementation(rootProject.libs.ktor.server.content.negotiation) + implementation(rootProject.libs.ktor.serialization.kotlinx.json) + implementation(rootProject.libs.ktor.server.cors) + implementation(rootProject.libs.ktor.server.call.logging) + implementation(rootProject.libs.ktor.server.http.redirect) + implementation(rootProject.libs.ktor.server.status.pages) + implementation(rootProject.libs.ktor.server.websockets) + implementation(rootProject.libs.ktor.server.metrics.micrometer) + implementation(rootProject.libs.ktor.server.metrics.micrometer.jvm) + implementation(rootProject.libs.micrometer.registry.prometheus) + implementation(rootProject.libs.kotlinx.coroutines.core) + implementation(rootProject.libs.logback) + implementation(rootProject.libs.webauthn4j.core) + implementation(rootProject.libs.slf4j.api) testImplementation(testFixtures(project(":domain"))) - testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.9.0") - testImplementation("io.ktor:ktor-server-test-host:2.3.12") - testImplementation("io.ktor:ktor-client-content-negotiation:2.3.12") - testImplementation("io.ktor:ktor-serialization-kotlinx-json:2.3.12") - testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.9.0") + testImplementation(rootProject.libs.kotlinx.coroutines.test) + testImplementation(rootProject.libs.ktor.server.test.host) + testImplementation(rootProject.libs.ktor.client.content.negotiation) + testImplementation(rootProject.libs.ktor.serialization.kotlinx.json) + testImplementation(rootProject.libs.ktor.serialization.kotlinx.json) }