diff --git a/examples/kotlin-kts/build.gradle.kts b/examples/kotlin-kts/build.gradle.kts index 66977c03..c54f516f 100644 --- a/examples/kotlin-kts/build.gradle.kts +++ b/examples/kotlin-kts/build.gradle.kts @@ -8,11 +8,11 @@ import org.jetbrains.kotlin.gradle.tasks.* plugins { java kotlin("jvm") - kotlin("plugin.allopen") version "1.9.0" + kotlin("plugin.allopen") version "1.9.21" id("org.jetbrains.kotlinx.benchmark") } -sourceSets.all { +sourceSets.configureEach { java.setSrcDirs(listOf("$name/src")) resources.setSrcDirs(listOf("$name/resources")) } diff --git a/examples/kotlin-multiplatform/build.gradle b/examples/kotlin-multiplatform/build.gradle index 3f916b89..c80cc595 100644 --- a/examples/kotlin-multiplatform/build.gradle +++ b/examples/kotlin-multiplatform/build.gradle @@ -4,7 +4,7 @@ import kotlinx.benchmark.gradle.JsBenchmarksExecutor plugins { id 'org.jetbrains.kotlin.multiplatform' - id 'org.jetbrains.kotlin.plugin.allopen' version "1.9.0" + id 'org.jetbrains.kotlin.plugin.allopen' version "1.9.21" id 'org.jetbrains.kotlinx.benchmark' } @@ -28,7 +28,7 @@ kotlin { if (HostManager.hostIsLinux) linuxX64('native') if (HostManager.hostIsMingw) mingwX64('native') - sourceSets.all { + sourceSets.configureEach { languageSettings { progressiveMode = true } diff --git a/examples/kotlin/build.gradle b/examples/kotlin/build.gradle index 16916f5f..cd694936 100644 --- a/examples/kotlin/build.gradle +++ b/examples/kotlin/build.gradle @@ -1,7 +1,7 @@ plugins { id 'java' id 'org.jetbrains.kotlin.jvm' - id 'org.jetbrains.kotlin.plugin.allopen' version "1.9.0" + id 'org.jetbrains.kotlin.plugin.allopen' version "1.9.21" id 'org.jetbrains.kotlinx.benchmark' } @@ -16,7 +16,7 @@ sourceSets { benchmarks } -sourceSets.all { +sourceSets.configureEach { kotlin.srcDirs = ["$it.name/src"] java.srcDirs = ["$it.name/src"] resources.srcDirs = ["$it.name/resources"] diff --git a/gradle.properties b/gradle.properties index 67014227..9c731027 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,7 +1,7 @@ group=org.jetbrains.kotlinx version=0.5.0-SNAPSHOT -kotlin_version=1.9.0 +kotlin_version=1.9.21 jmhVersion=1.21 infra_version=0.3.0-dev-74 kotlin.code.style=official diff --git a/integration/src/main/kotlin/kotlinx/benchmark/integration/BenchmarkConfiguration.kt b/integration/src/main/kotlin/kotlinx/benchmark/integration/BenchmarkConfiguration.kt index 2c66f336..3360994e 100644 --- a/integration/src/main/kotlin/kotlinx/benchmark/integration/BenchmarkConfiguration.kt +++ b/integration/src/main/kotlin/kotlinx/benchmark/integration/BenchmarkConfiguration.kt @@ -8,10 +8,10 @@ class BenchmarkConfiguration { var mode: String? = null var outputTimeUnit: String? = null var reportFormat: String? = null - var includes: MutableList = mutableListOf() - var excludes: MutableList = mutableListOf() - var params: MutableMap> = mutableMapOf() - var advanced: MutableMap = mutableMapOf() + private var includes: MutableList = mutableListOf() + private var excludes: MutableList = mutableListOf() + private var params: MutableMap> = mutableMapOf() + private var advanced: MutableMap = mutableMapOf() fun include(pattern: String) { includes.add(pattern) @@ -41,7 +41,7 @@ class BenchmarkConfiguration { reportFormat = ${reportFormat?.escape()} includes = ${includes.map { it.escape() }} excludes = ${excludes.map { it.escape() }} - ${params.entries.joinToString(separator = "\n") { """param("${it.key}", ${it?.value?.joinToString()})""" }} + ${params.entries.joinToString(separator = "\n") { """param("${it.key}", ${it.value.joinToString()})""" }} ${advanced.entries.joinToString(separator = "\n") { """advanced("${it.key}", ${if (it.value is String) "\"${it.value}\"" else it.value})""" }} diff --git a/plugin/gradle.properties b/plugin/gradle.properties index b9e1f9a8..285684db 100644 --- a/plugin/gradle.properties +++ b/plugin/gradle.properties @@ -1,7 +1,7 @@ group=org.jetbrains.kotlinx version=0.5.0-SNAPSHOT -kotlin_version=1.9.0 +kotlin_version=1.9.21 jmhVersion=1.21 infra_version=0.3.0-dev-74 diff --git a/plugin/main/src/kotlinx/benchmark/gradle/BenchmarksExtension.kt b/plugin/main/src/kotlinx/benchmark/gradle/BenchmarksExtension.kt index 28c7f444..4bbfbd67 100644 --- a/plugin/main/src/kotlinx/benchmark/gradle/BenchmarksExtension.kt +++ b/plugin/main/src/kotlinx/benchmark/gradle/BenchmarksExtension.kt @@ -53,7 +53,7 @@ open class BenchmarksExtension(val project: Project) { val target = multiplatform.targets.findByName(name) // We allow the name to be either a target or a source set when (val compilation = target?.compilations?.findByName(KotlinCompilation.MAIN_COMPILATION_NAME) - ?: multiplatform.targets.flatMap { it.compilations }.find { it.defaultSourceSetName == name }) { + ?: multiplatform.targets.flatMap { it.compilations }.find { it.defaultSourceSet.name == name }) { null -> { project.logger.warn("Warning: Cannot find a benchmark compilation '$name', ignoring.") BenchmarkTarget(this, name) // ignore diff --git a/plugin/main/src/kotlinx/benchmark/gradle/BenchmarksPlugin.kt b/plugin/main/src/kotlinx/benchmark/gradle/BenchmarksPlugin.kt index c6edd059..f3798f0c 100644 --- a/plugin/main/src/kotlinx/benchmark/gradle/BenchmarksPlugin.kt +++ b/plugin/main/src/kotlinx/benchmark/gradle/BenchmarksPlugin.kt @@ -37,8 +37,8 @@ class BenchmarksPlugin : Plugin { plugins.withType(org.jetbrains.kotlin.gradle.plugin.KotlinBasePlugin::class.java) { kotlinPlugin -> logger.info("Detected Kotlin plugin version '${kotlinPlugin.pluginVersion}'") - if (!getKotlinVersion(kotlinPlugin.pluginVersion).isAtLeast(1, 9, 0)) { - logger.error("JetBrains Gradle Benchmarks plugin requires Kotlin version 1.9.0 or higher") + if (!getKotlinVersion(kotlinPlugin.pluginVersion).isAtLeast(1, 9, 20)) { + logger.error("JetBrains Gradle Benchmarks plugin requires Kotlin version 1.9.20 or higher") } } diff --git a/plugin/main/src/kotlinx/benchmark/gradle/JsMultiplatformTasks.kt b/plugin/main/src/kotlinx/benchmark/gradle/JsMultiplatformTasks.kt index c357bd2b..7d70e9bd 100644 --- a/plugin/main/src/kotlinx/benchmark/gradle/JsMultiplatformTasks.kt +++ b/plugin/main/src/kotlinx/benchmark/gradle/JsMultiplatformTasks.kt @@ -46,18 +46,20 @@ private fun Project.createJsBenchmarkCompileTask(target: JsBenchmarkTarget): Kot ) } - compileKotlinTask.apply { - group = BenchmarksPlugin.BENCHMARKS_TASK_GROUP - description = "Compile JS benchmark source files for '${target.name}'" + compileTaskProvider.configure { + it.apply { + group = BenchmarksPlugin.BENCHMARKS_TASK_GROUP + description = "Compile JS benchmark source files for '${target.name}'" - //TODO: fix destination dir after KT-29711 is fixed - //println("JS: ${kotlinOptions.outputFile}") - //destinationDir = file("$benchmarkBuildDir/classes") - dependsOn("${target.name}${BenchmarksPlugin.BENCHMARK_GENERATE_SUFFIX}") + //TODO: fix destination dir after KT-29711 is fixed + //println("JS: ${kotlinOptions.outputFile}") + //destinationDir = file("$benchmarkBuildDir/classes") + dependsOn("${target.name}${BenchmarksPlugin.BENCHMARK_GENERATE_SUFFIX}") - kotlinOptions.apply { - sourceMap = true - moduleKind = "umd" + kotlinOptions.apply { + sourceMap = true + moduleKind = "umd" + } } } } diff --git a/plugin/main/src/kotlinx/benchmark/gradle/NativeMultiplatformTasks.kt b/plugin/main/src/kotlinx/benchmark/gradle/NativeMultiplatformTasks.kt index b9e3eaa7..301fb47d 100644 --- a/plugin/main/src/kotlinx/benchmark/gradle/NativeMultiplatformTasks.kt +++ b/plugin/main/src/kotlinx/benchmark/gradle/NativeMultiplatformTasks.kt @@ -62,7 +62,7 @@ private fun Project.createNativeBenchmarkCompileTask(target: NativeBenchmarkTarg // a link task. So we disable execution the klib compiling task to save time. // benchmarkCompilation.compileKotlinTask.enabled = false - benchmarkCompilation.compileKotlinTask.dependsOn(generateSourceTaskName(target)) + benchmarkCompilation.compileTaskProvider.configure { it.dependsOn(generateSourceTaskName(target)) } benchmarkCompilation.apply { val sourceSet = kotlinSourceSets.single() diff --git a/plugin/main/src/kotlinx/benchmark/gradle/WasmMultiplatformTasks.kt b/plugin/main/src/kotlinx/benchmark/gradle/WasmMultiplatformTasks.kt index 117646d7..8308e877 100644 --- a/plugin/main/src/kotlinx/benchmark/gradle/WasmMultiplatformTasks.kt +++ b/plugin/main/src/kotlinx/benchmark/gradle/WasmMultiplatformTasks.kt @@ -42,10 +42,12 @@ private fun Project.createWasmBenchmarkCompileTask(target: WasmBenchmarkTarget): ) } } - compileKotlinTask.apply { - group = BenchmarksPlugin.BENCHMARKS_TASK_GROUP - description = "Compile Wasm benchmark source files for '${target.name}'" - dependsOn("${target.name}${BenchmarksPlugin.BENCHMARK_GENERATE_SUFFIX}") + compileTaskProvider.configure { + it.apply { + group = BenchmarksPlugin.BENCHMARKS_TASK_GROUP + description = "Compile Wasm benchmark source files for '${target.name}'" + dependsOn("${target.name}${BenchmarksPlugin.BENCHMARK_GENERATE_SUFFIX}") + } } } return benchmarkCompilation diff --git a/runtime/build.gradle b/runtime/build.gradle index f2b980d0..32e0cecf 100644 --- a/runtime/build.gradle +++ b/runtime/build.gradle @@ -51,7 +51,13 @@ kotlin { js("jsIr", IR) { nodejs() } wasm("wasmJs") { d8() } - sourceSets.all { + targets.configureEach { + compilations.configureEach { + kotlinOptions.freeCompilerArgs += "-Xexpect-actual-classes" + } + } + + sourceSets.configureEach { kotlin.srcDirs = ["$it.name/src"] resources.srcDirs = ["$it.name/resources"] languageSettings { diff --git a/runtime/jsMain/src/kotlinx/benchmark/JsBenchmarkAnnotations.kt b/runtime/jsMain/src/kotlinx/benchmark/JsBenchmarkAnnotations.kt index 6ba95b2d..2c17e109 100644 --- a/runtime/jsMain/src/kotlinx/benchmark/JsBenchmarkAnnotations.kt +++ b/runtime/jsMain/src/kotlinx/benchmark/JsBenchmarkAnnotations.kt @@ -4,9 +4,16 @@ actual enum class Scope { Benchmark } +@Target(AnnotationTarget.CLASS) actual annotation class State(actual val value: Scope) + +@Target(AnnotationTarget.FUNCTION) actual annotation class Setup + +@Target(AnnotationTarget.FUNCTION) actual annotation class TearDown + +@Target(AnnotationTarget.FUNCTION) actual annotation class Benchmark diff --git a/runtime/nativeMain/src/kotlinx/benchmark/NativeBenchmarkAnnotations.kt b/runtime/nativeMain/src/kotlinx/benchmark/NativeBenchmarkAnnotations.kt index 11615a39..2b680f9d 100644 --- a/runtime/nativeMain/src/kotlinx/benchmark/NativeBenchmarkAnnotations.kt +++ b/runtime/nativeMain/src/kotlinx/benchmark/NativeBenchmarkAnnotations.kt @@ -4,9 +4,16 @@ actual enum class Scope { Benchmark } +@Target(AnnotationTarget.CLASS) actual annotation class State(actual val value: Scope) + +@Target(AnnotationTarget.FUNCTION) actual annotation class Setup + +@Target(AnnotationTarget.FUNCTION) actual annotation class TearDown + +@Target(AnnotationTarget.FUNCTION) actual annotation class Benchmark diff --git a/runtime/wasmJsMain/src/kotlinx/benchmark/WasmBenchmarkAnnotations.kt b/runtime/wasmJsMain/src/kotlinx/benchmark/WasmBenchmarkAnnotations.kt index 6ba95b2d..2c17e109 100644 --- a/runtime/wasmJsMain/src/kotlinx/benchmark/WasmBenchmarkAnnotations.kt +++ b/runtime/wasmJsMain/src/kotlinx/benchmark/WasmBenchmarkAnnotations.kt @@ -4,9 +4,16 @@ actual enum class Scope { Benchmark } +@Target(AnnotationTarget.CLASS) actual annotation class State(actual val value: Scope) + +@Target(AnnotationTarget.FUNCTION) actual annotation class Setup + +@Target(AnnotationTarget.FUNCTION) actual annotation class TearDown + +@Target(AnnotationTarget.FUNCTION) actual annotation class Benchmark