From db3ec4f8a72f169ae30ba43030c837a241409b96 Mon Sep 17 00:00:00 2001 From: petertrr Date: Sat, 28 Aug 2021 13:29:25 +0300 Subject: [PATCH] Dependency updates ### What's done: * Update gradle to 7.2 * Enable version catalog, add libs.versions.toml * Update kotlin and other dependencies * Fix build --- buildSrc/build.gradle.kts | 2 +- buildSrc/src/main/kotlin/Versions.kt | 9 ------- .../src/main/kotlin/code-coverage.gradle.kts | 4 ++-- ...common-kotlin-jvm-configuration.gradle.kts | 10 ++++---- gradle/libs.versions.toml | 24 +++++++++++++++++++ gradle/wrapper/gradle-wrapper.properties | 2 +- initiative-bot-core/build.gradle.kts | 4 ++-- .../petertrr/initbot/CommandParserTest.kt | 2 +- initiative-bot-discord/build.gradle.kts | 18 +++++++------- settings.gradle.kts | 2 ++ 10 files changed, 48 insertions(+), 29 deletions(-) delete mode 100644 buildSrc/src/main/kotlin/Versions.kt create mode 100644 gradle/libs.versions.toml diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index 69e6fbd..ed6c5c5 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -8,5 +8,5 @@ repositories { } dependencies { - implementation(kotlin("gradle-plugin", "1.5.21")) + implementation(kotlin("gradle-plugin", "1.5.30")) } \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/Versions.kt b/buildSrc/src/main/kotlin/Versions.kt deleted file mode 100644 index 4758207..0000000 --- a/buildSrc/src/main/kotlin/Versions.kt +++ /dev/null @@ -1,9 +0,0 @@ -object Versions { - const val kotlin = "1.5.20" - const val coroutines = "1.5.0" - const val junit = "5.7.1" - const val mockito = "3.11.2" - const val discord4j = "3.1.5" - const val slf4j = "1.7.30" - const val logback = "1.2.3" -} diff --git a/buildSrc/src/main/kotlin/code-coverage.gradle.kts b/buildSrc/src/main/kotlin/code-coverage.gradle.kts index 2770211..662a160 100644 --- a/buildSrc/src/main/kotlin/code-coverage.gradle.kts +++ b/buildSrc/src/main/kotlin/code-coverage.gradle.kts @@ -16,7 +16,7 @@ tasks.named("test") { tasks.named("jacocoTestReport") { dependsOn(tasks.named("test")) reports { - xml.isEnabled = true - html.isEnabled = true + xml.required.set(true) + html.required.set(true) } } diff --git a/buildSrc/src/main/kotlin/common-kotlin-jvm-configuration.gradle.kts b/buildSrc/src/main/kotlin/common-kotlin-jvm-configuration.gradle.kts index e272bd8..ccef233 100644 --- a/buildSrc/src/main/kotlin/common-kotlin-jvm-configuration.gradle.kts +++ b/buildSrc/src/main/kotlin/common-kotlin-jvm-configuration.gradle.kts @@ -2,7 +2,7 @@ import org.gradle.kotlin.dsl.dependencies import org.gradle.kotlin.dsl.kotlin import org.gradle.kotlin.dsl.version import org.gradle.kotlin.dsl.withType -import org.jetbrains.kotlin.gradle.dsl.KotlinCompile +import org.jetbrains.kotlin.gradle.dsl.KotlinJvmCompile plugins { kotlin("jvm") @@ -10,11 +10,13 @@ plugins { dependencies { testImplementation(kotlin("test-junit5")) - testImplementation("org.junit.jupiter:junit-jupiter-api:${Versions.junit}") - testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:${Versions.junit}") + val junit = "5.7.2" + testImplementation("org.junit.jupiter:junit-jupiter-api:$junit") + testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:$junit") } -tasks.withType>().configureEach { +tasks.withType().configureEach { + kotlinOptions.jvmTarget = "14" kotlinOptions.freeCompilerArgs += "-Xopt-in=kotlin.RequiresOptIn" } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml new file mode 100644 index 0000000..70ae04e --- /dev/null +++ b/gradle/libs.versions.toml @@ -0,0 +1,24 @@ +[versions] +kotlin = "1.5.30" +kotlinx-coroutines = "1.5.1" +junit = "5.7.2" +mockito = "3.11.2" +discord4j = "3.1.5" +reactor = "1.1.4" +slf4j = "1.7.30" +logback = "1.2.3" + +[plugins] +kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } + +[libraries] +kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlinx-coroutines" } +kotlinx-coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "kotlinx-coroutines" } +kotlinx-coroutines-reactor = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-reactor", version.ref = "kotlinx-coroutines" } +mockito-core = { module = "org.mockito:mockito-core", version.ref = "mockito" } +mockito-junit-jupiter = { module = "org.mockito:mockito-junit-jupiter", version.ref = "mockito" } +microutils-logging = { module = "io.github.microutils:kotlin-logging", version = "2.0.11" } +reactor-kotlin-extensions = { module = "io.projectreactor.kotlin:reactor-kotlin-extensions", version.ref = "reactor" } +discord4j-core = { module = "com.discord4j:discord4j-core", version.ref = "discord4j" } +logback-core = { module = "ch.qos.logback:logback-core", version.ref = "logback" } +logback-classic = { module = "ch.qos.logback:logback-classic", version.ref = "logback" } \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 05679dc..ffed3a2 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.1.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/initiative-bot-core/build.gradle.kts b/initiative-bot-core/build.gradle.kts index 927de17..b06f462 100644 --- a/initiative-bot-core/build.gradle.kts +++ b/initiative-bot-core/build.gradle.kts @@ -4,6 +4,6 @@ plugins { } dependencies { - testImplementation("org.mockito:mockito-core:${Versions.mockito}") - testImplementation("org.mockito:mockito-junit-jupiter:${Versions.mockito}") + testImplementation(libs.mockito.core) + testImplementation(libs.mockito.junit.jupiter) } diff --git a/initiative-bot-core/src/test/kotlin/io/github/petertrr/initbot/CommandParserTest.kt b/initiative-bot-core/src/test/kotlin/io/github/petertrr/initbot/CommandParserTest.kt index 5114bd1..a941f48 100644 --- a/initiative-bot-core/src/test/kotlin/io/github/petertrr/initbot/CommandParserTest.kt +++ b/initiative-bot-core/src/test/kotlin/io/github/petertrr/initbot/CommandParserTest.kt @@ -19,7 +19,7 @@ class CommandParserTest { "round" to Round, "roll +2" to Roll(defaultName, 2), "roll +2 Tom" to Roll("Tom", 2), - "next" to Countdown(60), + "next" to Countdown(45), ).forEach { (rawCommand, expectedCommand) -> Assertions.assertEquals(expectedCommand, Command.parse(rawCommand, defaultName, defaultRoundDuration)) } diff --git a/initiative-bot-discord/build.gradle.kts b/initiative-bot-discord/build.gradle.kts index 85a66b9..cf06ff6 100644 --- a/initiative-bot-discord/build.gradle.kts +++ b/initiative-bot-discord/build.gradle.kts @@ -5,15 +5,15 @@ plugins { } dependencies { - implementation(project(":initiative-bot-core")) - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:${Versions.coroutines}") - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-reactor:${Versions.coroutines}") - implementation("io.projectreactor.kotlin:reactor-kotlin-extensions:1.1.3") - implementation("com.discord4j:discord4j-core:${Versions.discord4j}") - implementation("io.github.microutils:kotlin-logging:2.0.8") - implementation("ch.qos.logback:logback-core:${Versions.logback}") - runtimeOnly("ch.qos.logback:logback-classic:${Versions.logback}") - testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:${Versions.coroutines}") + implementation(projects.initiativeBotCore) + implementation(libs.kotlinx.coroutines.core) + implementation(libs.kotlinx.coroutines.reactor) + implementation(libs.reactor.kotlin.extensions) + implementation(libs.discord4j.core) + implementation(libs.microutils.logging) + implementation(libs.logback.core) + implementation(libs.logback.classic) + testImplementation(libs.kotlinx.coroutines.test) } application { diff --git a/settings.gradle.kts b/settings.gradle.kts index 2948d8f..7b81b34 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,4 +1,6 @@ rootProject.name = "initiative-bot" +enableFeaturePreview("VERSION_CATALOGS") +enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS") include("initiative-bot-core") include("initiative-bot-discord") \ No newline at end of file