From b0bdf9c56e711f72a1bf37b8ff9e67beb591df86 Mon Sep 17 00:00:00 2001 From: David Hoepelman <992153+dhoepelman@users.noreply.github.com> Date: Mon, 9 Sep 2024 11:59:44 +0200 Subject: [PATCH] Use libs.versions.toml --- build.gradle.kts | 63 ++++++++++++++++++++++++++++----------- gradle/libs.versions.toml | 18 +++++++++++ 2 files changed, 63 insertions(+), 18 deletions(-) create mode 100644 gradle/libs.versions.toml diff --git a/build.gradle.kts b/build.gradle.kts index 4a780d7..1f7fa1d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -20,11 +20,12 @@ val jvm = JvmTarget.JVM_1_8 val onCI: Boolean = System.getenv("CI")?.toBooleanLenient() ?: false plugins { - kotlin("multiplatform") version "2.0.20" + alias(libs.plugins.kotest.multiplatform) + alias(libs.plugins.kotlin.multiplatform) + alias(libs.plugins.ktlint) + alias(libs.plugins.nexuspublish) id("maven-publish") id("signing") - id("io.github.gradle-nexus.publish-plugin") version "2.0.0" - id("org.jlleitschuh.gradle.ktlint") version "12.1.1" idea } @@ -36,6 +37,7 @@ group = projectGroup val projectVersion = System.getenv("CI_VERSION") ?: "0.6.2-SNAPSHOT" version = projectVersion +//region Kotlin and test configuration kotlin { // Since we are a library, prevent accidentally making things part of the public API explicitApi() @@ -47,15 +49,12 @@ kotlin { } } - // start of kotlin targets + //region kotlin targets androidNativeArm32() androidNativeArm64() androidNativeX86() androidNativeX64() jvm { - testRuns["test"].executionTask.configure { - useJUnitPlatform() - } @OptIn(ExperimentalKotlinGradlePluginApi::class) compilerOptions { // note lang toolchain cannot be used here @@ -93,25 +92,49 @@ kotlin { wasmWasi { nodejs() } - // end of kotlin targets + //endregion sourceSets { - commonMain { - dependencies { - api(kotlin("stdlib")) - } + // Shared dependencies + commonMain.dependencies { + api(kotlin("stdlib")) } - commonTest { - dependencies { - implementation(kotlin("test")) - } + // Shared test dependencies + commonTest.dependencies { + implementation(kotlin("test")) + // implementation(kotlin("test-annotations-common")) + // implementation(kotlin("test-common")) + // implementation(libs.kotest.assertions.core) + // implementation(libs.kotest.framework.datatest) + // implementation(libs.kotest.framework.engine) + } + jvmTest.dependencies { + // implementation(libs.kotest.runner.junit5) } } } configure { - version = "1.3.1" + version = libs.versions.ktlint.get() } +tasks.named("jvmTest") { + useJUnitPlatform() + filter { + isFailOnNoMatchingTests = true + } + testLogging { + showExceptions = true + showStandardStreams = true + events = + setOf( + org.gradle.api.tasks.testing.logging.TestLogEvent.FAILED, + org.gradle.api.tasks.testing.logging.TestLogEvent.PASSED, + ) + exceptionFormat = org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL + } +} +//endregion +//region Publishing configuration val javaDocJar = tasks.register("stubJavadoc") { archiveClassifier = "javadoc" @@ -163,7 +186,8 @@ signing { } sign(publishing.publications) } -//region Fix Gradle warning about signing tasks using publishing task outputs without explicit dependencies + +// Fix Gradle warning about signing tasks using publishing task outputs without explicit dependencies // https://github.com/gradle/gradle/issues/26091 tasks.withType().configureEach { val signingTasks = tasks.withType() @@ -180,10 +204,13 @@ nexusPublishing { } } } +//endregion +//region IDE configuration idea { module { isDownloadJavadoc = true isDownloadSources = true } } +//endregion diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml new file mode 100644 index 0000000..25862b5 --- /dev/null +++ b/gradle/libs.versions.toml @@ -0,0 +1,18 @@ +[versions] +kotest = "5.9.1" +kotlin = "2.0.20" +ktlint = "1.3.1" + +[libraries] +kotest-assertions-core = { module = "io.kotest:kotest-assertions-core", version.ref = "kotest" } +kotest-framework-datatest = { module = "io.kotest:kotest-framework-datatest", version.ref = "kotest" } +kotest-framework-engine = { module = "io.kotest:kotest-framework-engine", version.ref = "kotest" } +kotest-runner-junit5 = { module = "io.kotest:kotest-runner-junit5", version.ref = "kotest" } +# Not actually used as dependency, but hopefully this causes dependabot to pick up on ktlint versions +ktlint = { module = "com.pinterest:ktlint-bom", version.ref = "ktlint" } + +[plugins] +kotest-multiplatform = { id = "io.kotest.multiplatform", version.ref = "kotest" } +kotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" } +ktlint = { id = "org.jlleitschuh.gradle.ktlint", version = "12.1.1" } +nexuspublish = { id = "io.github.gradle-nexus.publish-plugin", version = "2.0.0" }