Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump Kotlin version to 2.0.20 #255

Merged
merged 12 commits into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
`kotlinx-benchmark` is a toolkit for running benchmarks for multiplatform code written in Kotlin.
It is designed to work with Kotlin/JVM, Kotlin/JS, Kotlin/Native, and Kotlin/Wasm (experimental) targets.

To get started, ensure you're using Kotlin 1.9.20 or newer and Gradle 7.4 or newer.
To get started, ensure you're using Kotlin 2.0.0 or newer and Gradle 7.4 or newer.
adam-enko marked this conversation as resolved.
Show resolved Hide resolved

## Features

Expand Down Expand Up @@ -180,7 +180,7 @@ To run benchmarks in Kotlin/JVM:
```kotlin
// build.gradle.kts
plugins {
kotlin("plugin.allopen") version "1.9.20"
kotlin("plugin.allopen") version "2.0.20"
}

allOpen {
Expand Down Expand Up @@ -213,7 +213,7 @@ To run benchmarks in Kotlin/JVM:
```kotlin
// build.gradle.kts
plugins {
kotlin("plugin.allopen") version "1.9.20"
kotlin("plugin.allopen") version "2.0.20"
}

allOpen {
Expand Down
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ apiValidation {

val checkReadme by tasks.registering(CheckReadmeTask::class) {
minSupportedGradleVersion = libs.versions.minSupportedGradle
minSupportedKotlinVersion = libs.versions.minSupportedKotlin
readme = file("README.md")
}

Expand Down
17 changes: 11 additions & 6 deletions buildSrc/src/main/kotlin/tasks/CheckReadmeTask.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import org.gradle.api.tasks.PathSensitivity.*
abstract class CheckReadmeTask : DefaultTask() {
@get:Input
abstract val minSupportedGradleVersion: Property<String>
@get:Input
abstract val minSupportedKotlinVersion: Property<String>

@get:InputFile
@get:PathSensitive(RELATIVE)
Expand All @@ -20,23 +22,26 @@ abstract class CheckReadmeTask : DefaultTask() {
val readmeContents = readme.readText()

val minSupportedGradleVersion = minSupportedGradleVersion.get()
val minSupportedKotlinVersion = minSupportedKotlinVersion.get()

val matches = Regex("Gradle (?<version>[^ ]+) or newer").findAll(readmeContents).toList()
val matches = Regex("Kotlin (?<kotlinVersion>[^ ]+) or newer and Gradle (?<gradleVersion>[^ ]+) or newer")
.findAll(readmeContents).toList()

require(matches.size >= 1) {
"""
$readme does not contain correct min supported Gradle version.
$readme does not contain correct min supported Kotlin and Gradle versions.
${matches.size} matches found.
""".trimIndent()
}

matches.forEach { match ->
val version = match.groups["version"]?.value ?: error("Regex failed - could not find version")
require(minSupportedGradleVersion == version) {
val kotlinVersion = match.groups["kotlinVersion"]?.value ?: error("Regex failed - could not find kotlinVersion")
val gradleVersion = match.groups["gradleVersion"]?.value ?: error("Regex failed - could not find gradleVersion")
require(minSupportedKotlinVersion == kotlinVersion && minSupportedGradleVersion == gradleVersion) {
"""
$readme does not contain correct min supported Gradle version
$readme does not contain correct min supported Kotlin and Gradle versions.
Actual: ${match.value}
Expected: Gradle $minSupportedGradleVersion or newer
Expected: Kotlin $minSupportedKotlinVersion or newer and Gradle $minSupportedGradleVersion or newer
""".trimIndent()
}
}
Expand Down
6 changes: 3 additions & 3 deletions docs/kotlin-jvm-project-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ To configure Kotlin/JVM and Java projects for benchmarking, follow these steps:
```kotlin
// build.gradle.kts
plugins {
kotlin("plugin.allopen") version "1.9.20"
kotlin("plugin.allopen") version "2.0.20"
}

allOpen {
Expand All @@ -129,7 +129,7 @@ To configure Kotlin/JVM and Java projects for benchmarking, follow these steps:
```groovy
// build.gradle
plugins {
id 'org.jetbrains.kotlin.plugin.allopen' version "1.9.20"
id 'org.jetbrains.kotlin.plugin.allopen' version "2.0.20"
}

allOpen {
Expand Down Expand Up @@ -164,7 +164,7 @@ To configure Kotlin/JVM and Java projects for benchmarking, follow these steps:
```kotlin
// build.gradle.kts
plugins {
kotlin("plugin.allopen") version "1.9.20"
kotlin("plugin.allopen") version "2.0.20"
}

allOpen {
Expand Down
2 changes: 1 addition & 1 deletion examples/kotlin-kts/build.gradle.kts
adam-enko marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import org.jetbrains.kotlin.gradle.tasks.*
plugins {
java
kotlin("jvm")
adam-enko marked this conversation as resolved.
Show resolved Hide resolved
kotlin("plugin.allopen") version "1.9.21"
kotlin("plugin.allopen") version "2.0.20"
id("org.jetbrains.kotlinx.benchmark")
}

Expand Down
15 changes: 2 additions & 13 deletions examples/kotlin-multiplatform/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import kotlinx.benchmark.gradle.JsBenchmarksExecutor

plugins {
id 'org.jetbrains.kotlin.multiplatform'
id 'org.jetbrains.kotlin.plugin.allopen' version "1.9.21"
id 'org.jetbrains.kotlin.plugin.allopen' version "2.0.20"
id 'org.jetbrains.kotlinx.benchmark'
}

Expand All @@ -15,7 +15,7 @@ kotlin {
jvm {
compilations.create('benchmark') { associateWith(compilations.main) }
}
js(IR) {
js {
nodejs()
compilations.create("defaultExecutor") { associateWith(compilations.main) }
compilations.create("builtInExecutor") { associateWith(compilations.main) }
Expand Down Expand Up @@ -135,14 +135,3 @@ benchmark {
register("mingwX64")
}
}

// Node.js with canary v8 that supports recent Wasm GC changes
rootProject.extensions.findByType(org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension.class).with {
nodeVersion = "21.0.0-v8-canary202309167e82ab1fa2"
nodeDownloadBaseUrl = "https://nodejs.org/download/v8-canary"
}

// Drop this when node js version become stable
rootProject.tasks.withType(org.jetbrains.kotlin.gradle.targets.js.npm.tasks.KotlinNpmInstallTask.class).configureEach {
args.add("--ignore-engines")
}
2 changes: 1 addition & 1 deletion examples/kotlin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import kotlinx.benchmark.gradle.JvmBenchmarkTarget

plugins {
kotlin("jvm")
id("org.jetbrains.kotlin.plugin.allopen") version "1.9.21"
id("org.jetbrains.kotlin.plugin.allopen") version "2.0.20"
id("org.jetbrains.kotlinx.benchmark")
}

Expand Down
3 changes: 2 additions & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
[versions]

# Note: Kotlin version can be overridden by passing `-Pkotlin_version=<version>`
kotlin = "1.9.21"
kotlin = "2.0.20"
kotlinx-binaryCompatibilityValidator = "0.16.2"
kotlinx-teamInfra = "0.4.0-dev-81"
squareup-kotlinpoet = "1.3.0"
jmh = "1.21"
gradle-pluginPublish = "0.21.0"

minSupportedGradle = "7.4"
minSupportedKotlin = "2.0.0"

[libraries]

Expand Down
1 change: 1 addition & 0 deletions integration/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ tasks.test {
systemProperty("kotlin_repo_url", rootProject.properties["kotlin_repo_url"])
systemProperty("kotlin_version", libs.versions.kotlin.get())
systemProperty("minSupportedGradleVersion", libs.versions.minSupportedGradle.get())
systemProperty("minSupportedKotlinVersion", libs.versions.minSupportedKotlin.get())
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ enum class GradleTestVersion(val versionString: String) {
v8_0("8.0.2"),
MinSupportedGradleVersion("7.4"),
UnsupportedGradleVersion("7.3"),
MinSupportedKotlinVersion("2.0.0"),
UnsupportedKotlinVersion("1.9.20"),
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,14 @@ class Runner(
if (print) forwardStdOutput(System.out.bufferedWriter()) else this
}

fun run(vararg tasks: String, fn: BuildResult.() -> Unit = {}) {
fun run(vararg tasks: String, fn: BuildResult.() -> Unit) {
val gradle = gradle(*tasks)
@Suppress("UnstableApiUsage")
val buildResult = gradle.run()
buildResult.fn()
}

fun runAndSucceed(vararg tasks: String, fn: BuildResult.() -> Unit = {}) {
val gradle = gradle(*tasks)
val buildResult = gradle.build()
buildResult.fn()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class AnnotationsValidationTest : GradleTest() {
assertOutputContains(error)
}
} else {
runner.run(platformBenchmarkTask) {
runner.runAndSucceed(platformBenchmarkTask) {
assertOutputContains("BUILD SUCCESSFUL")
}
}
Expand All @@ -44,7 +44,7 @@ class AnnotationsValidationTest : GradleTest() {
assertOutputContains(jvmSpecificError)
}
} else {
runner.run("jvmBenchmark") {
runner.runAndSucceed("jvmBenchmark") {
assertOutputContains("BUILD SUCCESSFUL")
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@ class ConfigurationCacheTest : GradleTest() {
}
}

project.run(*invokedTasks.toTypedArray(), "--configuration-cache") {
project.runAndSucceed(*invokedTasks.toTypedArray(), "--configuration-cache") {
assertTasksExecuted(invokedTasks + executedTasks)
assertConfigurationCacheStored()
}
project.run("clean", "--configuration-cache") {
project.runAndSucceed("clean", "--configuration-cache") {
assertConfigurationCacheStored()
}
project.run(*invokedTasks.toTypedArray(), "--configuration-cache") {
project.runAndSucceed(*invokedTasks.toTypedArray(), "--configuration-cache") {
assertTasksExecuted(invokedTasks + executedTasks)
assertConfigurationCacheReused()
}
project.run(*invokedTasks.toTypedArray(), "--configuration-cache") {
project.runAndSucceed(*invokedTasks.toTypedArray(), "--configuration-cache") {
assertTasksUpToDate(executedTasks)
assertConfigurationCacheReused()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class InvalidTargetingTest : GradleTest() {
@Test
fun testWasmNodeJs() {
val runner = project("invalid-target/wasm-nodejs", true)
runner.run("wasmJsBenchmark") // Successful
runner.runAndSucceed("wasmJsBenchmark")
}

@Test
Expand All @@ -26,14 +26,6 @@ class InvalidTargetingTest : GradleTest() {
}
}

@Test
fun testJsLegacyBackend() {
val runner = project("invalid-target/js-legacy", true)
runner.runAndFail("jsBenchmark") {
assertOutputContains("Legacy Kotlin/JS backend is not supported. Please migrate to the Kotlin/JS IR compiler backend.")
}
}

@Test
fun testJsBrowser() {
val runner = project("invalid-target/js-browser", true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class JvmToolchainsTest : GradleTest() {
fun testJvmToolchainSetup() {
val runner = project("kmp-with-toolchain", true, GradleTestVersion.v8_0) {
}
runner.run("benchmark") {
runner.runAndSucceed("benchmark") {
assertEquals(TaskOutcome.SUCCESS, task(":jvmBenchmark")!!.outcome)
assertOutputDoesNotContain("<failure>")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ class KotlinNativeTest : GradleTest() {
val target = "native"
val capitalizedTarget = target.replaceFirstChar { it.uppercaseChar() }

runner.run(":${target}BenchmarkGenerate")
runner.run(":compile${capitalizedTarget}BenchmarkKotlin${capitalizedTarget}")
runner.run(":${capitalizedTarget}Benchmark")
runner.runAndSucceed(":${target}BenchmarkGenerate")
runner.runAndSucceed(":compile${capitalizedTarget}BenchmarkKotlin${capitalizedTarget}")
runner.runAndSucceed(":${capitalizedTarget}Benchmark")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class OptionsOverrideAnnotationsTest : GradleTest() {
configuration("config") {
setupBlock()
}
}.run("nativeConfigBenchmark") {
}.runAndSucceed("nativeConfigBenchmark") {
val reportText = reports("config").single().readText()
checkBlock(reportText, output)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class OptionsValidationTest : GradleTest() {
mode = "AverageTime"
}
}
runner.run("validOptionsBenchmark") // Successful
runner.runAndSucceed("validOptionsBenchmark")
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class ReportFormatTest : GradleTest() {
@Test
fun testReportFormatFileNames() {
val formats = listOf(null, "json", "csv", "scsv", "text")
val targets = listOf("jsIr", "wasmJs", "jvm", "native")
val targets = listOf("js", "wasmJs", "jvm", "native")

val runner = project("kotlin-multiplatform", true) {
formats.forEach { format ->
Expand All @@ -24,7 +24,7 @@ class ReportFormatTest : GradleTest() {
formats.forEach { format ->
val name = format ?: "jsonDefault"
val ext = format ?: "json"
runner.run("${name}Benchmark")
runner.runAndSucceed("${name}Benchmark")
val reports = reports(name)
assertEquals(targets.size, reports.size)
assertEquals(targets.map { "$it.$ext" }.toSet(), reports.map(File::getName).toSet())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class SourceSetAsBenchmarkTargetTest : GradleTest() {
fun testSupportForSourceSetsAsBenchmarkTargets() {
val jvmBenchmark = "jvmBenchmark"
val configuration = "jsonDefault"
val targets = listOf("jsIr", "wasmJs", "jvm", "native", jvmBenchmark)
val targets = listOf("js", "wasmJs", "jvm", "native", jvmBenchmark)

val runner =
project("kotlin-multiplatform", true) {
Expand All @@ -21,7 +21,7 @@ class SourceSetAsBenchmarkTargetTest : GradleTest() {
register(jvmBenchmark) { jmhVersion = "1.21" }
}

runner.run("${configuration}Benchmark")
runner.runAndSucceed("${configuration}Benchmark")
val reports = reports(configuration)
assertEquals(targets.size, reports.size)
assertEquals(targets.map { "$it.json" }.toSet(), reports.map(File::getName).toSet())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class SuiteSourceGeneratorTest : GradleTest() {
private inline fun testSourceGenerator(setupBlock: Runner.() -> Unit, checkBlock: Runner.() -> Unit) {
project("source-generation").apply {
setupBlock()
run("nativeBenchmarkGenerate")
runAndSucceed("nativeBenchmarkGenerate")
checkBlock()
}
}
Expand Down Expand Up @@ -159,7 +159,7 @@ class SuiteSourceGeneratorTest : GradleTest() {

@Test
fun generateAndCompileJSBenchmarks() {
generateAndCompile("jsIr")
generateAndCompile("js")
}

@Test
Expand All @@ -169,7 +169,7 @@ class SuiteSourceGeneratorTest : GradleTest() {

private fun generateAndCompile(target: String) {
project("kotlin-multiplatform", true).let { runner ->
runner.run(":${target}BenchmarkGenerate")
runner.runAndSucceed(":${target}BenchmarkGenerate")

runner.generatedDir(target, "RootBenchmark_Descriptor.kt") { descriptorFile ->
val text = descriptorFile.readText()
Expand All @@ -180,7 +180,7 @@ class SuiteSourceGeneratorTest : GradleTest() {
}

val capitalizedTarget = target.replaceFirstChar { it.uppercaseChar() }
runner.run(":compile${capitalizedTarget}BenchmarkKotlin${capitalizedTarget}")
runner.runAndSucceed(":compile${capitalizedTarget}BenchmarkKotlin${capitalizedTarget}")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class SupportedGradleVersionTest : GradleTest() {
fun `when using min supported Gradle version, expect no warning`() {
val runner = project("kotlin-multiplatform", gradleVersion = GradleTestVersion.MinSupportedGradleVersion)

runner.run(":help", "-q") {
runner.runAndSucceed(":help", "-q") {
assertOutputDoesNotContain(warningMessage)
}
}
Expand All @@ -39,7 +39,7 @@ class SupportedGradleVersionTest : GradleTest() {
fun `when using unsupported Gradle version, expect warning`() {
val runner = project("kotlin-multiplatform", gradleVersion = GradleTestVersion.UnsupportedGradleVersion)

runner.run(":help", "-q") {
runner.runAndSucceed(":help", "-q") {
assertOutputContains(warningMessage)
}
}
Expand Down
Loading