From 58c6508d0a2af8e9a9a4999e818c10315c49fa31 Mon Sep 17 00:00:00 2001 From: Billy Brawner Date: Thu, 2 Jun 2022 20:28:44 -0600 Subject: [PATCH] Use gradle version catalogs --- api/build.gradle.kts | 14 +++++------ app/build.gradle.kts | 22 +++++++--------- build.gradle.kts | 6 ++--- core/build.gradle.kts | 12 ++++----- db/build.gradle.kts | 10 ++++---- gradle/libs.versions.toml | 32 ++++++++++++++++++++++++ gradle/wrapper/gradle-wrapper.properties | 2 +- settings.gradle.kts | 2 +- storage/build.gradle.kts | 8 +++--- testhelpers/build.gradle.kts | 6 ++--- web/build.gradle.kts | 10 +++----- 11 files changed, 71 insertions(+), 53 deletions(-) create mode 100644 gradle/libs.versions.toml diff --git a/api/build.gradle.kts b/api/build.gradle.kts index 4b49c2a..2afc7b2 100644 --- a/api/build.gradle.kts +++ b/api/build.gradle.kts @@ -1,20 +1,18 @@ plugins { kotlin("jvm") - kotlin("plugin.serialization") version "1.5.20" + alias(libs.plugins.kotlin.serialization) `java-library` } -val ktorVersion: String by rootProject.extra - dependencies { implementation(kotlin("stdlib")) api(project(":core")) implementation(project(":storage")) - api("io.ktor:ktor-server-core:$ktorVersion") - api("io.ktor:ktor-serialization:$ktorVersion") - api("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2") - testImplementation("org.junit.jupiter:junit-jupiter-api:5.8.2") - testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine") + api(libs.ktor.server.core) + api(libs.ktor.serialization) + api(libs.kotlin.coroutines.core) + testImplementation(libs.junit.jupiter.api) + testRuntimeOnly(libs.junit.jupiter.engine) } tasks.getByName("test") { diff --git a/app/build.gradle.kts b/app/build.gradle.kts index fc3c2d6..3408ee9 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -5,7 +5,7 @@ plugins { java kotlin("jvm") application - id("com.github.johnrengelman.shadow") version "7.0.0" + alias(libs.plugins.shadow) } repositories { @@ -16,24 +16,20 @@ repositories { } } -val kotlinVersion: String by rootProject.extra -val ktorVersion: String by rootProject.extra - dependencies { implementation(project(":api")) implementation(project(":core")) implementation(project(":db")) implementation(project(":web")) - implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlinVersion") - implementation("org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion") - implementation("io.ktor:ktor-server-core:$ktorVersion") - implementation("io.ktor:ktor-server-cio:$ktorVersion") - implementation("io.ktor:ktor-server-sessions:$ktorVersion") - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2") - implementation("ch.qos.logback:logback-classic:1.2.8") + implementation(libs.kotlin.reflect) + implementation(libs.ktor.server.core) + implementation(libs.ktor.server.cio) + implementation(libs.ktor.server.sessions) + implementation(libs.kotlin.coroutines.core) + implementation(libs.logback) testImplementation(project(":testhelpers")) - testImplementation("org.junit.jupiter:junit-jupiter-api:5.8.2") - testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine") + testImplementation(libs.junit.jupiter.api) + testRuntimeOnly(libs.junit.jupiter.engine) } description = "twigs-server" diff --git a/build.gradle.kts b/build.gradle.kts index 8c17ef3..82e6929 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -2,21 +2,19 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile import java.net.URI buildscript { - val kotlinVersion: String by extra("1.6.10") - val ktorVersion: String by extra("1.6.6") repositories { mavenLocal() mavenCentral() } dependencies { - classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion") + classpath(libs.kotlin.gradle) } } plugins { java - kotlin("jvm") version "1.5.20" + alias(libs.plugins.kotlin.jvm) } allprojects { diff --git a/core/build.gradle.kts b/core/build.gradle.kts index c3142ae..0c3db56 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -1,16 +1,14 @@ plugins { - kotlin("jvm") `java-library` + kotlin("jvm") } -val ktorVersion: String by rootProject.extra - dependencies { implementation(kotlin("stdlib")) - api("io.ktor:ktor-auth:$ktorVersion") - api("at.favre.lib:bcrypt:0.9.0") - testImplementation("org.junit.jupiter:junit-jupiter-api:5.8.2") - testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine") + api(libs.ktor.auth) + api(libs.bcrypt) + testImplementation(libs.junit.jupiter.api) + testRuntimeOnly(libs.junit.jupiter.engine) } tasks.getByName("test") { diff --git a/db/build.gradle.kts b/db/build.gradle.kts index 2e98fcf..f2681c8 100644 --- a/db/build.gradle.kts +++ b/db/build.gradle.kts @@ -8,11 +8,11 @@ val ktorVersion: String by rootProject.extra dependencies { implementation(kotlin("stdlib")) api(project(":storage")) - implementation("org.postgresql:postgresql:42.3.1") - api("com.zaxxer:HikariCP:5.0.0") - implementation("ch.qos.logback:logback-classic:1.2.8") - testImplementation("org.junit.jupiter:junit-jupiter-api:5.8.2") - testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine") + implementation(libs.postgres) + api(libs.hikari) + implementation(libs.logback) + testImplementation(libs.junit.jupiter.api) + testRuntimeOnly(libs.junit.jupiter.engine) } tasks.getByName("test") { diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml new file mode 100644 index 0000000..28384ce --- /dev/null +++ b/gradle/libs.versions.toml @@ -0,0 +1,32 @@ +[versions] +bcrypt = "0.9.0" +hikari = "5.0.1" +junit = "5.8.2" +kotlin = "1.6.21" +kotlin-coroutines = "1.6.1" +ktor = "1.6.6" +logback = "1.2.11" +postgres = "42.3.4" +shadow = "7.0.0" + +[libraries] +bcrypt = { module = "at.favre.lib:bcrypt", version.ref = "bcrypt" } +hikari = { module = "com.zaxxer:HikariCP", version.ref = "hikari" } +junit-jupiter-api = { module = "org.junit.jupiter:junit-jupiter-api", version.ref = "junit" } +junit-jupiter-engine = { module = "org.junit.jupiter:junit-jupiter-engine" } +kotlin-coroutines-core = { module = "org.jetbrains.kotlin:kotlin-coroutines-core", version.ref = "kotlin-coroutines" } +kotlin-coroutines-test = { module = "org.jetbrains.kotlin:kotlin-coroutines-test", version.ref = "kotlin-coroutines" } +kotlin-gradle = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" } +kotlin-reflect = { module = "org.jetbrains.kotlin:kotlin-reflect", version.ref = "kotlin" } +ktor-auth = { module = "io.ktor:ktor-auth", version.ref = "ktor" } +ktor-serialization = { module = "io.ktor:ktor-serialization", version.ref = "ktor" } +ktor-server-cio = { module = "io.ktor:ktor-server-cio", version.ref = "ktor" } +ktor-server-core = { module = "io.ktor:ktor-server-core", version.ref = "ktor" } +ktor-server-sessions = { module = "io.ktor:ktor-server-sessions", version.ref = "ktor" } +logback = { module = "ch.qos.logback:logback-classic", version.ref = "logback" } +postgres = { module = "org.postgresql:postgresql", version.ref = "postgres" } + +[plugins] +kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } +kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" } +shadow = { id = "com.github.johnrengelman.shadow", version.ref = "shadow" } \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 716c2d3..7b22bd6 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ #Fri Feb 07 18:11:46 CST 2020 -distributionUrl=https\://services.gradle.org/distributions/gradle-7.1.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-all.zip distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStorePath=wrapper/dists diff --git a/settings.gradle.kts b/settings.gradle.kts index 865fc01..a1af3bb 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,3 +1,3 @@ rootProject.name = "twigs" include("core", "api", "app", "storage", "db", "web") -include("testhelpers") +include("testhelpers") \ No newline at end of file diff --git a/storage/build.gradle.kts b/storage/build.gradle.kts index 6a20899..69bb5d7 100644 --- a/storage/build.gradle.kts +++ b/storage/build.gradle.kts @@ -3,14 +3,12 @@ plugins { `java-library` } -val ktorVersion: String by rootProject.extra - dependencies { implementation(kotlin("stdlib")) api(project(":core")) - api("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2") - testImplementation("org.junit.jupiter:junit-jupiter-api:5.8.2") - testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine") + api(libs.kotlin.coroutines.core) + testImplementation(libs.junit.jupiter.api) + testRuntimeOnly(libs.junit.jupiter.engine) } tasks.getByName("test") { diff --git a/testhelpers/build.gradle.kts b/testhelpers/build.gradle.kts index 4c34b1f..0dd86f2 100644 --- a/testhelpers/build.gradle.kts +++ b/testhelpers/build.gradle.kts @@ -6,7 +6,7 @@ plugins { dependencies { implementation(kotlin("stdlib")) implementation(project(":storage")) - api("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.5.2") - api("org.junit.jupiter:junit-jupiter-api:5.8.2") - api("org.junit.jupiter:junit-jupiter-engine") + api(libs.kotlin.coroutines.test) + api(libs.junit.jupiter.api) + runtimeOnly(libs.junit.jupiter.engine) } diff --git a/web/build.gradle.kts b/web/build.gradle.kts index c73ae45..40bd3cb 100644 --- a/web/build.gradle.kts +++ b/web/build.gradle.kts @@ -1,17 +1,15 @@ import java.util.* plugins { - kotlin("jvm") `java-library` + alias(libs.plugins.kotlin.jvm) } -val ktorVersion: String by rootProject.extra - dependencies { implementation(kotlin("stdlib")) - api("io.ktor:ktor-server-core:$ktorVersion") - testImplementation("org.junit.jupiter:junit-jupiter-api:5.8.2") - testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine") + api(libs.ktor.server.core) + testImplementation(libs.junit.jupiter.api) + testRuntimeOnly(libs.junit.jupiter.engine) } tasks.getByName("test") {