From 645342be9c28acdb581e7aab8f74bc0b72950942 Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Wed, 23 Nov 2022 13:25:31 +0300 Subject: [PATCH] Port to Kotlin 1.8.0-Beta --- benchmarks/build.gradle.kts | 10 ++-------- buildSrc/build.gradle.kts | 7 ++----- .../kscience/kmath/benchmarks/JmhReport.kt | 5 ----- .../benchmarks/addBenchmarkProperties.kt | 8 ++++---- gradle.properties | 2 +- kmath-ast/build.gradle.kts | 2 +- kmath-core/build.gradle.kts | 2 +- kmath-functions/build.gradle.kts | 2 +- .../space/kscience/kmath/memory/Memory.kt | 2 +- settings.gradle.kts | 19 +++++++++++++++++++ 10 files changed, 32 insertions(+), 27 deletions(-) diff --git a/benchmarks/build.gradle.kts b/benchmarks/build.gradle.kts index 9c8dc613a..d4b2c6f1c 100644 --- a/benchmarks/build.gradle.kts +++ b/benchmarks/build.gradle.kts @@ -5,7 +5,7 @@ import space.kscience.kmath.benchmarks.addBenchmarkProperties plugins { kotlin("multiplatform") - kotlin("plugin.allopen") + alias(npmlibs.plugins.kotlin.plugin.allopen) id("org.jetbrains.kotlinx.benchmark") } @@ -50,6 +50,7 @@ kotlin { val jvmMain by getting { dependencies { + implementation("org.openjdk.jmh:jmh-core:1.36") implementation(project(":kmath-commons")) implementation(project(":kmath-ejml")) implementation(project(":kmath-nd4j")) @@ -144,13 +145,6 @@ benchmark { } } -// Fix kotlinx-benchmarks bug -afterEvaluate { - val jvmBenchmarkJar by tasks.getting(org.gradle.jvm.tasks.Jar::class) { - duplicatesStrategy = DuplicatesStrategy.EXCLUDE - } -} - kotlin.sourceSets.all { with(languageSettings) { optIn("kotlin.contracts.ExperimentalContracts") diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index 0f95a7b3f..412853dcb 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -1,7 +1,6 @@ plugins { `kotlin-dsl` `version-catalog` - kotlin("plugin.serialization") version "1.6.21" } java.targetCompatibility = JavaVersion.VERSION_11 @@ -15,16 +14,14 @@ repositories { val toolsVersion = npmlibs.versions.tools.get() val kotlinVersion = npmlibs.versions.kotlin.asProvider().get() -val benchmarksVersion = npmlibs.versions.kotlinx.benchmark.get() +val benchmarksVersion = "0.4.6" dependencies { api("space.kscience:gradle-tools:$toolsVersion") - api(npmlibs.atomicfu.gradle) //plugins form benchmarks api("org.jetbrains.kotlinx:kotlinx-benchmark-plugin:$benchmarksVersion") - api("org.jetbrains.kotlin:kotlin-allopen:$kotlinVersion") //to be used inside build-script only - implementation(npmlibs.kotlinx.serialization.json) + implementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.14.1") } kotlin.sourceSets.all { diff --git a/buildSrc/src/main/kotlin/space/kscience/kmath/benchmarks/JmhReport.kt b/buildSrc/src/main/kotlin/space/kscience/kmath/benchmarks/JmhReport.kt index 62cf44915..3a4fcdc79 100644 --- a/buildSrc/src/main/kotlin/space/kscience/kmath/benchmarks/JmhReport.kt +++ b/buildSrc/src/main/kotlin/space/kscience/kmath/benchmarks/JmhReport.kt @@ -5,9 +5,6 @@ package space.kscience.kmath.benchmarks -import kotlinx.serialization.Serializable - -@Serializable data class JmhReport( val jmhVersion: String, val benchmark: String, @@ -37,7 +34,6 @@ data class JmhReport( val scoreUnit: String } - @Serializable data class PrimaryMetric( override val score: Double, override val scoreError: Double, @@ -48,7 +44,6 @@ data class JmhReport( val rawData: List>? = null, ) : Metric - @Serializable data class SecondaryMetric( override val score: Double, override val scoreError: Double, diff --git a/buildSrc/src/main/kotlin/space/kscience/kmath/benchmarks/addBenchmarkProperties.kt b/buildSrc/src/main/kotlin/space/kscience/kmath/benchmarks/addBenchmarkProperties.kt index 5c6a2ac83..2c255329a 100644 --- a/buildSrc/src/main/kotlin/space/kscience/kmath/benchmarks/addBenchmarkProperties.kt +++ b/buildSrc/src/main/kotlin/space/kscience/kmath/benchmarks/addBenchmarkProperties.kt @@ -5,9 +5,9 @@ package space.kscience.kmath.benchmarks +import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper +import com.fasterxml.jackson.module.kotlin.readValue import kotlinx.benchmark.gradle.BenchmarksExtension -import kotlinx.serialization.decodeFromString -import kotlinx.serialization.json.Json import org.gradle.api.Project import space.kscience.gradle.KScienceReadmeExtension import java.time.LocalDateTime @@ -46,6 +46,7 @@ private val ISO_DATE_TIME: DateTimeFormatter = DateTimeFormatterBuilder().run { private fun noun(number: Number, singular: String, plural: String) = if (number.toLong() == 1L) singular else plural fun Project.addBenchmarkProperties() { + val mapper = jacksonObjectMapper() val benchmarksProject = this rootProject.subprojects.forEach { p -> p.extensions.findByType(KScienceReadmeExtension::class.java)?.run { @@ -60,8 +61,7 @@ fun Project.addBenchmarkProperties() { if (resDirectory == null || !(resDirectory.resolve("jvm.json")).exists()) { "> **Can't find appropriate benchmark data. Try generating readme files after running benchmarks**." } else { - val reports = - Json.decodeFromString>(resDirectory.resolve("jvm.json").readText()) + val reports: List = mapper.readValue>(resDirectory.resolve("jvm.json")) buildString { appendLine("
") diff --git a/gradle.properties b/gradle.properties index da5867ea4..60c51c3dd 100644 --- a/gradle.properties +++ b/gradle.properties @@ -10,7 +10,7 @@ kotlin.incremental.js.ir=true org.gradle.configureondemand=true org.gradle.jvmargs=-Xmx4096m -toolsVersion=0.13.1-kotlin-1.7.20 +toolsVersion=0.13.3-kotlin-1.8.0-Beta org.gradle.parallel=true diff --git a/kmath-ast/build.gradle.kts b/kmath-ast/build.gradle.kts index 7fd0f43f7..8913800d7 100644 --- a/kmath-ast/build.gradle.kts +++ b/kmath-ast/build.gradle.kts @@ -6,7 +6,7 @@ kscience{ native() } -kotlin.js { +kotlin.js(org.jetbrains.kotlin.gradle.plugin.KotlinJsCompilerType.IR) { nodejs { testTask { useMocha().timeout = "0" diff --git a/kmath-core/build.gradle.kts b/kmath-core/build.gradle.kts index f33d33324..d9d4e1131 100644 --- a/kmath-core/build.gradle.kts +++ b/kmath-core/build.gradle.kts @@ -6,7 +6,7 @@ kscience{ native() dependencies { - api(project(":kmath-memory")) + api(projects.kmath.kmathMemory) } } diff --git a/kmath-functions/build.gradle.kts b/kmath-functions/build.gradle.kts index 2e7b023c1..0baf6fa11 100644 --- a/kmath-functions/build.gradle.kts +++ b/kmath-functions/build.gradle.kts @@ -11,7 +11,7 @@ description = "Functions, integration and interpolation" kotlin.sourceSets { commonMain { dependencies { - api(project(":kmath-core")) + api(projects.kmathCore) } } } diff --git a/kmath-memory/src/commonMain/kotlin/space/kscience/kmath/memory/Memory.kt b/kmath-memory/src/commonMain/kotlin/space/kscience/kmath/memory/Memory.kt index 006d57c5f..68ada6c89 100644 --- a/kmath-memory/src/commonMain/kotlin/space/kscience/kmath/memory/Memory.kt +++ b/kmath-memory/src/commonMain/kotlin/space/kscience/kmath/memory/Memory.kt @@ -9,7 +9,7 @@ import kotlin.contracts.InvocationKind import kotlin.contracts.contract /** - * Represents a display of certain memory structure. + * Represents a view of certain memory structure. */ public interface Memory { /** diff --git a/settings.gradle.kts b/settings.gradle.kts index 23af18d31..c3abd6446 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -19,6 +19,25 @@ dependencyResolutionManagement { } } +pluginManagement { + + val toolsVersion: String by extra + + repositories { + mavenLocal() + maven("https://repo.kotlin.link") + mavenCentral() + gradlePluginPortal() + } + + plugins { + id("space.kscience.gradle.project") version toolsVersion + id("space.kscience.gradle.mpp") version toolsVersion + id("space.kscience.gradle.jvm") version toolsVersion + id("space.kscience.gradle.js") version toolsVersion + } +} + include( ":test-utils", ":kmath-memory",