From ac886f36c8fbac7f0b9bf66fe62c8acd594432e7 Mon Sep 17 00:00:00 2001 From: "Flemming N. Larsen" Date: Mon, 2 Dec 2024 22:48:06 +0100 Subject: [PATCH] Updated to kotest 6.0.0.M1 causing issue with build script for the Bot API for .Net. This script was refactored and improved. The deprecated `exec {}` was replaced. --- bot-api/dotnet/build.gradle.kts | 71 ++++++++++++++++----------------- gradle/test-libs.versions.toml | 5 ++- 2 files changed, 37 insertions(+), 39 deletions(-) diff --git a/bot-api/dotnet/build.gradle.kts b/bot-api/dotnet/build.gradle.kts index 9913a31d5..e64968faf 100644 --- a/bot-api/dotnet/build.gradle.kts +++ b/bot-api/dotnet/build.gradle.kts @@ -34,41 +34,38 @@ tasks { into("docs") } - assemble { - dependsOn(":schema:dotnet:build", prepareNugetDocs) + val buildDotnetBotApi by registering(Exec::class) { + dependsOn(prepareNugetDocs) - doLast { - exec { - workingDir("Robocode.TankRoyale.BotApi") - commandLine("dotnet", "build", "--configuration", "Release", "-p:Version=$version") - } - } + workingDir("Robocode.TankRoyale.BotApi") + commandLine("dotnet", "build", "--configuration", "Release", "-p:Version=$version") } - register("test") { - doLast { - exec { - workingDir("Robocode.TankRoyale.BotApi.Tests") - commandLine("dotnet", "test") - } - } + val test by registering(Exec::class) { + workingDir("Robocode.TankRoyale.BotApi.Tests") + commandLine("dotnet", "test") + } + + build { + dependsOn(":schema:dotnet:build", buildDotnetBotApi) + } + + val docfxMetadata by registering(Exec::class) { + workingDir("docfx_project") + commandLine("docfx", "metadata") + } + + val docfxBuild by registering(Exec::class) { + workingDir("docfx_project") + delete("_site", "api", "obj") + commandLine("docfx", "build") } val docfx by registering { - doLast { - exec { - workingDir("docfx_project") - commandLine("docfx", "metadata") // build /api before building the _site - } - exec { - workingDir("docfx_project") - delete("_site", "api", "obj") - commandLine("docfx", "build") // build /_site - } - } + dependsOn(docfxMetadata, docfxBuild) } - register("uploadDocs") { + val uploadDocs by registering(Copy::class) { dependsOn(clean, docfx) val dotnetApiDir = "../../docs/api/dotnet" @@ -82,17 +79,17 @@ tasks { into(dotnetApiDir) } - register("pushLocal") { - dependsOn(build, prepareNugetDocs) + val pushLocal by registering(Exec::class) { + dependsOn(prepareNugetDocs) - doLast { - val userhome = System.getenv("USERPROFILE") ?: System.getenv("HOME") - println("$userhome/.nuget/packages/${artifactName.lowercase()}/$version") - delete("$userhome/.nuget/packages/${artifactName.lowercase()}/$version") - exec { - workingDir("Robocode.TankRoyale.BotApi/bin/Release") - commandLine("dotnet", "nuget", "push", "$artifactName.$version.nupkg", "--source", "$userhome/.nuget/packages") - } + val userHome = System.getenv("USERPROFILE") ?: System.getenv("HOME") + + doFirst { + println("$userHome/.nuget/packages/${artifactName.lowercase()}/$version") + delete("$userHome/.nuget/packages/${artifactName.lowercase()}/$version") } + + workingDir("Robocode.TankRoyale.BotApi/bin/Release") + commandLine("dotnet", "nuget", "push", "$artifactName.$version.nupkg", "--source", "$userHome/.nuget/packages") } } \ No newline at end of file diff --git a/gradle/test-libs.versions.toml b/gradle/test-libs.versions.toml index 505f8c87b..21faec910 100644 --- a/gradle/test-libs.versions.toml +++ b/gradle/test-libs.versions.toml @@ -3,7 +3,8 @@ assertj = "3.26.3" junit = "5.11.3" system-stubs = "2.1.7" -kotest = "5.9.1" +kotest = "6.0.0.M1" +kotest-datatest = "5.9.1" mockk = "1.13.13" [libraries] @@ -17,7 +18,7 @@ system-stubs = { module = "uk.org.webcompere:system-stubs-jupiter", version.ref # Kotlin testing kotest-junit5 = { module = "io.kotest:kotest-runner-junit5-jvm", version.ref = "kotest" } -kotest-datatest = { module = "io.kotest:kotest-framework-datatest", version.ref = "kotest" } +kotest-datatest = { module = "io.kotest:kotest-framework-datatest", version.ref = "kotest-datatest" } mockk = { module = "io.mockk:mockk", version.ref = "mockk" } [bundles]