Port to Kotlin 1.8.0-Beta

This commit is contained in:
Alexander Nozik 2022-11-23 13:25:31 +03:00
parent b14e2fdd08
commit 645342be9c
No known key found for this signature in database
GPG Key ID: F7FCF2DD25C71357
10 changed files with 32 additions and 27 deletions

View File

@ -5,7 +5,7 @@ import space.kscience.kmath.benchmarks.addBenchmarkProperties
plugins { plugins {
kotlin("multiplatform") kotlin("multiplatform")
kotlin("plugin.allopen") alias(npmlibs.plugins.kotlin.plugin.allopen)
id("org.jetbrains.kotlinx.benchmark") id("org.jetbrains.kotlinx.benchmark")
} }
@ -50,6 +50,7 @@ kotlin {
val jvmMain by getting { val jvmMain by getting {
dependencies { dependencies {
implementation("org.openjdk.jmh:jmh-core:1.36")
implementation(project(":kmath-commons")) implementation(project(":kmath-commons"))
implementation(project(":kmath-ejml")) implementation(project(":kmath-ejml"))
implementation(project(":kmath-nd4j")) 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 { kotlin.sourceSets.all {
with(languageSettings) { with(languageSettings) {
optIn("kotlin.contracts.ExperimentalContracts") optIn("kotlin.contracts.ExperimentalContracts")

View File

@ -1,7 +1,6 @@
plugins { plugins {
`kotlin-dsl` `kotlin-dsl`
`version-catalog` `version-catalog`
kotlin("plugin.serialization") version "1.6.21"
} }
java.targetCompatibility = JavaVersion.VERSION_11 java.targetCompatibility = JavaVersion.VERSION_11
@ -15,16 +14,14 @@ repositories {
val toolsVersion = npmlibs.versions.tools.get() val toolsVersion = npmlibs.versions.tools.get()
val kotlinVersion = npmlibs.versions.kotlin.asProvider().get() val kotlinVersion = npmlibs.versions.kotlin.asProvider().get()
val benchmarksVersion = npmlibs.versions.kotlinx.benchmark.get() val benchmarksVersion = "0.4.6"
dependencies { dependencies {
api("space.kscience:gradle-tools:$toolsVersion") api("space.kscience:gradle-tools:$toolsVersion")
api(npmlibs.atomicfu.gradle)
//plugins form benchmarks //plugins form benchmarks
api("org.jetbrains.kotlinx:kotlinx-benchmark-plugin:$benchmarksVersion") api("org.jetbrains.kotlinx:kotlinx-benchmark-plugin:$benchmarksVersion")
api("org.jetbrains.kotlin:kotlin-allopen:$kotlinVersion")
//to be used inside build-script only //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 { kotlin.sourceSets.all {

View File

@ -5,9 +5,6 @@
package space.kscience.kmath.benchmarks package space.kscience.kmath.benchmarks
import kotlinx.serialization.Serializable
@Serializable
data class JmhReport( data class JmhReport(
val jmhVersion: String, val jmhVersion: String,
val benchmark: String, val benchmark: String,
@ -37,7 +34,6 @@ data class JmhReport(
val scoreUnit: String val scoreUnit: String
} }
@Serializable
data class PrimaryMetric( data class PrimaryMetric(
override val score: Double, override val score: Double,
override val scoreError: Double, override val scoreError: Double,
@ -48,7 +44,6 @@ data class JmhReport(
val rawData: List<List<Double>>? = null, val rawData: List<List<Double>>? = null,
) : Metric ) : Metric
@Serializable
data class SecondaryMetric( data class SecondaryMetric(
override val score: Double, override val score: Double,
override val scoreError: Double, override val scoreError: Double,

View File

@ -5,9 +5,9 @@
package space.kscience.kmath.benchmarks 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.benchmark.gradle.BenchmarksExtension
import kotlinx.serialization.decodeFromString
import kotlinx.serialization.json.Json
import org.gradle.api.Project import org.gradle.api.Project
import space.kscience.gradle.KScienceReadmeExtension import space.kscience.gradle.KScienceReadmeExtension
import java.time.LocalDateTime 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 private fun noun(number: Number, singular: String, plural: String) = if (number.toLong() == 1L) singular else plural
fun Project.addBenchmarkProperties() { fun Project.addBenchmarkProperties() {
val mapper = jacksonObjectMapper()
val benchmarksProject = this val benchmarksProject = this
rootProject.subprojects.forEach { p -> rootProject.subprojects.forEach { p ->
p.extensions.findByType(KScienceReadmeExtension::class.java)?.run { p.extensions.findByType(KScienceReadmeExtension::class.java)?.run {
@ -60,8 +61,7 @@ fun Project.addBenchmarkProperties() {
if (resDirectory == null || !(resDirectory.resolve("jvm.json")).exists()) { if (resDirectory == null || !(resDirectory.resolve("jvm.json")).exists()) {
"> **Can't find appropriate benchmark data. Try generating readme files after running benchmarks**." "> **Can't find appropriate benchmark data. Try generating readme files after running benchmarks**."
} else { } else {
val reports = val reports: List<JmhReport> = mapper.readValue<List<JmhReport>>(resDirectory.resolve("jvm.json"))
Json.decodeFromString<List<JmhReport>>(resDirectory.resolve("jvm.json").readText())
buildString { buildString {
appendLine("<details>") appendLine("<details>")

View File

@ -10,7 +10,7 @@ kotlin.incremental.js.ir=true
org.gradle.configureondemand=true org.gradle.configureondemand=true
org.gradle.jvmargs=-Xmx4096m 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 org.gradle.parallel=true

View File

@ -6,7 +6,7 @@ kscience{
native() native()
} }
kotlin.js { kotlin.js(org.jetbrains.kotlin.gradle.plugin.KotlinJsCompilerType.IR) {
nodejs { nodejs {
testTask { testTask {
useMocha().timeout = "0" useMocha().timeout = "0"

View File

@ -6,7 +6,7 @@ kscience{
native() native()
dependencies { dependencies {
api(project(":kmath-memory")) api(projects.kmath.kmathMemory)
} }
} }

View File

@ -11,7 +11,7 @@ description = "Functions, integration and interpolation"
kotlin.sourceSets { kotlin.sourceSets {
commonMain { commonMain {
dependencies { dependencies {
api(project(":kmath-core")) api(projects.kmathCore)
} }
} }
} }

View File

@ -9,7 +9,7 @@ import kotlin.contracts.InvocationKind
import kotlin.contracts.contract import kotlin.contracts.contract
/** /**
* Represents a display of certain memory structure. * Represents a view of certain memory structure.
*/ */
public interface Memory { public interface Memory {
/** /**

View File

@ -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( include(
":test-utils", ":test-utils",
":kmath-memory", ":kmath-memory",