diff --git a/build.gradle b/build.gradle deleted file mode 100644 index d95135e8..00000000 --- a/build.gradle +++ /dev/null @@ -1,49 +0,0 @@ -buildscript { - repositories { - maven { url 'https://maven.pkg.jetbrains.space/kotlin/p/kotlinx/maven' } - gradlePluginPortal() - - KotlinCommunity.addDevRepositoryIfEnabled(delegate, project) - } - - dependencies { - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath "kotlinx.team:kotlinx.team.infra:$infra_version" - } -} - -apply plugin: 'kotlinx.team.infra' - -infra { - teamcity { - libraryStagingRepoDescription = project.name - } - - publishing { - include(":kotlinx-benchmark-runtime") - - libraryRepoUrl = "https://github.com/Kotlin/kotlinx-benchmark" - - if (project.findProperty("publication_repository") == "sonatype") { - sonatype {} - } - } -} - -// https://youtrack.jetbrains.com/issue/KT-48410 -repositories { - mavenCentral() -} - -afterEvaluate { - gradle.includedBuilds.forEach { included -> - project(":kotlinx-benchmark-runtime").tasks.named("publishToMavenLocal") { dependsOn(included.task(":publishToMavenLocal")) } - } -} - -allprojects { - logger.info("Using Kotlin $kotlin_version for project $it") - repositories { - KotlinCommunity.addDevRepositoryIfEnabled(delegate, project) - } -} diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 00000000..dc3f4968 --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,57 @@ +import kotlinx.team.infra.* + +buildscript { + val kotlin_version: String by project + val infra_version: String by project + + repositories { + maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlinx/maven") + gradlePluginPortal() + + addDevRepositoryIfEnabled(this, project) + } + + dependencies { + classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version") + classpath("kotlinx.team:kotlinx.team.infra:$infra_version") + } +} + +apply(plugin = "kotlinx.team.infra") + +configure { + publishing { + include(":kotlinx-benchmark-runtime") + + libraryRepoUrl = "https://github.com/Kotlin/kotlinx-benchmark" + + if (project.findProperty("publication_repository") == "sonatype") { + sonatype { + libraryStagingRepoDescription = project.name + } + } + } +} + +// https://youtrack.jetbrains.com/issue/KT-48410 +repositories { + mavenCentral() +} + +afterEvaluate { + gradle.includedBuilds.forEach { included -> + project(":kotlinx-benchmark-runtime").tasks.named("publishToMavenLocal").configure { + dependsOn(included.task(":publishToMavenLocal")) + } + } +} + +allprojects { + val kotlin_version: String by project + val infra_version: String by project + + logger.info("Using Kotlin $kotlin_version for project ${this.name}") + repositories { + addDevRepositoryIfEnabled(this, project) + } +} diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index 6ef120d1..607d6dd5 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -7,8 +7,4 @@ plugins { repositories { mavenCentral() -} - -kotlinDslPluginOptions { - experimentalWarning.set(false) } \ No newline at end of file diff --git a/examples/build.gradle b/examples/build.gradle deleted file mode 100644 index 1ac34db0..00000000 --- a/examples/build.gradle +++ /dev/null @@ -1,8 +0,0 @@ -group 'org.jetbrains.kotlinx.benchmark.examples' -version '0.1-SNAPSHOT' - -subprojects { - repositories { - mavenCentral() - } -} diff --git a/examples/build.gradle.kts b/examples/build.gradle.kts new file mode 100644 index 00000000..6fef438b --- /dev/null +++ b/examples/build.gradle.kts @@ -0,0 +1,8 @@ +group "org.jetbrains.kotlinx.benchmark.examples" +version "0.1-SNAPSHOT" + +subprojects { + repositories { + mavenCentral() + } +} \ No newline at end of file diff --git a/examples/java/build.gradle b/examples/java/build.gradle.kts similarity index 66% rename from examples/java/build.gradle rename to examples/java/build.gradle.kts index 99533e69..d8ff165d 100644 --- a/examples/java/build.gradle +++ b/examples/java/build.gradle.kts @@ -1,26 +1,27 @@ +import kotlinx.benchmark.gradle.* + buildscript { dependencies { - classpath "org.jetbrains.kotlinx:kotlinx-benchmark-plugin" + classpath("org.jetbrains.kotlinx:kotlinx-benchmark-plugin") } } plugins { - id 'java' + java + id("org.jetbrains.kotlinx.benchmark") } -apply plugin: 'org.jetbrains.kotlinx.benchmark' - dependencies { implementation(project(":kotlinx-benchmark-runtime")) } benchmark { configurations { - main { + named("main") { iterationTime = 300 iterationTimeUnit = "ms" } - singleParam { + create("singleParam") { iterationTime = 300 iterationTimeUnit = "ms" param("stringValue", "C", "D") @@ -29,6 +30,7 @@ benchmark { } targets { register("main") { + this as JvmBenchmarkTarget jmhVersion = "1.21" } } diff --git a/examples/kotlin-multiplatform/build.gradle b/examples/kotlin-multiplatform/build.gradle.kts similarity index 64% rename from examples/kotlin-multiplatform/build.gradle rename to examples/kotlin-multiplatform/build.gradle.kts index d29eeda1..a1bbd375 100644 --- a/examples/kotlin-multiplatform/build.gradle +++ b/examples/kotlin-multiplatform/build.gradle.kts @@ -1,11 +1,12 @@ +import kotlinx.benchmark.gradle.* import org.jetbrains.kotlin.konan.target.HostManager import org.jetbrains.kotlin.konan.target.KonanTarget import kotlinx.benchmark.gradle.JsBenchmarksExecutor plugins { - id 'org.jetbrains.kotlin.multiplatform' - id 'org.jetbrains.kotlin.plugin.allopen' version "1.9.0" - id 'org.jetbrains.kotlinx.benchmark' + kotlin("multiplatform") + kotlin("plugin.allopen") version "1.9.0" + id("org.jetbrains.kotlinx.benchmark") } // how to apply plugin to a specific source set? @@ -15,15 +16,15 @@ allOpen { kotlin { jvm { - compilations.create('benchmark') { associateWith(compilations.main) } + compilations.create("benchmark") { associateWith(compilations.getByName("main")) } } - js('jsIr', IR) { nodejs() } - js('jsIrBuiltIn', IR) { nodejs() } - wasm('wasmJs') { d8() } - if (HostManager.host == KonanTarget.MACOS_X64.INSTANCE) macosX64('native') - if (HostManager.host == KonanTarget.MACOS_ARM64.INSTANCE) macosArm64('native') - if (HostManager.hostIsLinux) linuxX64('native') - if (HostManager.hostIsMingw) mingwX64('native') + js("jsIr", IR) { nodejs() } + js("jsIrBuiltIn", IR) { nodejs() } + wasm("wasmJs") { d8() } + if (HostManager.host == KonanTarget.MACOS_X64) macosX64("native") + if (HostManager.host == KonanTarget.MACOS_ARM64) macosArm64("native") + if (HostManager.hostIsLinux) linuxX64("native") + if (HostManager.hostIsMingw) mingwX64("native") sourceSets.all { languageSettings { @@ -32,23 +33,29 @@ kotlin { } sourceSets { - commonMain { + getByName("commonMain") { dependencies { - implementation project(":kotlinx-benchmark-runtime") + implementation(project(":kotlinx-benchmark-runtime")) } } - jvmMain {} + getByName("jvmMain") {} - wasmJsMain {} + getByName("wasmJsMain") {} - jsMain { - jsIrMain.dependsOn(it) - jsIrBuiltInMain.dependsOn(it) + + val jsMain by creating + + getByName("jsIrMain") { + dependsOn(jsMain) + } + + getByName("jsIrBuiltInMain") { + dependsOn(jsMain) } - nativeMain { - dependsOn(commonMain) + getByName("nativeMain") { + dependsOn(getByName("commonMain")) } } } @@ -56,7 +63,7 @@ kotlin { // Configure benchmark benchmark { configurations { - main { // --> jvmBenchmark, jsBenchmark, Benchmark, benchmark + named("main") { // --> jvmBenchmark, jsBenchmark, Benchmark, benchmark iterations = 5 // number of iterations iterationTime = 300 iterationTimeUnit = "ms" @@ -64,7 +71,7 @@ benchmark { advanced("jsUseBridge", true) } - params { + create("params") { iterations = 5 // number of iterations iterationTime = 300 iterationTimeUnit = "ms" @@ -73,7 +80,7 @@ benchmark { param("unused", 6, 9) } - fast { // --> jvmFastBenchmark, jsFastBenchmark, FastBenchmark, fastBenchmark + create("fast") { // --> jvmFastBenchmark, jsFastBenchmark, FastBenchmark, fastBenchmark include("Common") exclude("long") iterations = 5 @@ -82,7 +89,7 @@ benchmark { advanced("nativeGCAfterIteration", true) } - csv { + create("csv") { include("Common") exclude("long") iterations = 1 @@ -91,7 +98,7 @@ benchmark { reportFormat = "csv" // csv report format } - fork { + create("fork") { include("CommonBenchmark") iterations = 5 iterationTime = 300 @@ -106,15 +113,18 @@ benchmark { // This one matches target name, e.g. 'jvm', 'js', // and registers its 'main' compilation, so 'jvm' registers 'jvmMain' register("jvm") { + this as JvmBenchmarkTarget jmhVersion = "1.21" } // This one matches source set name, e.g. 'jvmMain', 'jvmTest', etc // and register the corresponding compilation (here the 'benchmark' compilation declared in the 'jvm' target) register("jvmBenchmark") { + this as JvmBenchmarkTarget jmhVersion = "1.21" } register("jsIr") register("jsIrBuiltIn") { + this as JsBenchmarkTarget jsBenchmarksExecutor = JsBenchmarksExecutor.BuiltIn } register("wasmJs") diff --git a/examples/kotlin/benchmarks/src/TestBenchmark.kt b/examples/kotlin/benchmarks/src/TestBenchmark.kt deleted file mode 100644 index 876f5d92..00000000 --- a/examples/kotlin/benchmarks/src/TestBenchmark.kt +++ /dev/null @@ -1,28 +0,0 @@ -package test - -import org.openjdk.jmh.annotations.* -import java.util.concurrent.* -import kotlin.math.* - -@State(Scope.Benchmark) -@Fork(1) -@Warmup(iterations = 0) -@Measurement(iterations = 1, time = 1, timeUnit = TimeUnit.SECONDS) -class TestBenchmark { - private var data: TestData = TestData(0.0) - - @Setup - fun setUp() { - data = TestData(3.0) - } - - @Benchmark - fun sqrtBenchmark(): Double { - return sqrt(data.value) - } - - @Benchmark - fun cosBenchmark(): Double { - return cos(data.value) - } -} \ No newline at end of file diff --git a/examples/kotlin/build.gradle b/examples/kotlin/build.gradle deleted file mode 100644 index 6d8ae8ac..00000000 --- a/examples/kotlin/build.gradle +++ /dev/null @@ -1,49 +0,0 @@ -plugins { - id 'java' - id 'org.jetbrains.kotlin.jvm' - id 'org.jetbrains.kotlin.plugin.allopen' version "1.9.0" - id 'org.jetbrains.kotlinx.benchmark' -} - - -// how to apply plugin to a specific source set? -allOpen { - annotation("org.openjdk.jmh.annotations.State") -} - -// Create a custom sourceSet -sourceSets { - benchmarks -} - -sourceSets.all { - kotlin.srcDirs = ["$it.name/src"] - java.srcDirs = ["$it.name/src"] - resources.srcDirs = ["$it.name/resources"] -} - -compileKotlin { - kotlinOptions.jvmTarget = "1.8" -} -compileTestKotlin { - kotlinOptions.jvmTarget = "1.8" -} - - -// Propagate dependencies from main sourceSet -// You can add "+ sourceSets.test.output" to include test output as well -dependencies { - implementation(project(":kotlinx-benchmark-runtime")) - benchmarksImplementation sourceSets.main.output + sourceSets.main.runtimeClasspath -} - -// Configure benchmark -benchmark { - // Setup configurations - targets { - // This one matches sourceSet name above - register("benchmarks") { - jmhVersion = "1.21" - } - } -} diff --git a/examples/kotlin-kts/build.gradle.kts b/examples/kotlin/build.gradle.kts similarity index 100% rename from examples/kotlin-kts/build.gradle.kts rename to examples/kotlin/build.gradle.kts diff --git a/examples/kotlin-kts/main/src/KtsTestBenchmark.kt b/examples/kotlin/main/src/KtsTestBenchmark.kt similarity index 100% rename from examples/kotlin-kts/main/src/KtsTestBenchmark.kt rename to examples/kotlin/main/src/KtsTestBenchmark.kt diff --git a/examples/kotlin/main/src/TestData.kt b/examples/kotlin/main/src/TestData.kt deleted file mode 100644 index fc941065..00000000 --- a/examples/kotlin/main/src/TestData.kt +++ /dev/null @@ -1,3 +0,0 @@ -package test - -data class TestData(var value: Double) \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index aa991fce..98debb84 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.2-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/integration/src/test/resources/templates/kotlin-multiplatform/build.gradle b/integration/src/test/resources/templates/kotlin-multiplatform/build.gradle index 08e4c84f..dcb5af90 100644 --- a/integration/src/test/resources/templates/kotlin-multiplatform/build.gradle +++ b/integration/src/test/resources/templates/kotlin-multiplatform/build.gradle @@ -3,15 +3,15 @@ import org.jetbrains.kotlin.konan.target.HostManager kotlin { jvm { - compilations.create('benchmark') { associateWith(compilations.main) } + compilations.create("benchmark") { associateWith(compilations.main) } } - js('jsIr', IR) { nodejs() } - wasm('wasmJs') { d8() } + js("jsIr", IR) { nodejs() } + wasm("wasmJs") { d8() } - if (HostManager.hostIsLinux) linuxX64('native') - if (HostManager.hostIsMingw) mingwX64('native') - if (HostManager.host == KonanTarget.MACOS_X64.INSTANCE) macosX64('native') - if (HostManager.host == KonanTarget.MACOS_ARM64.INSTANCE) macosArm64('native') + if (HostManager.hostIsLinux) linuxX64("native") + if (HostManager.hostIsMingw) mingwX64("native") + if (HostManager.host == KonanTarget.MACOS_X64.INSTANCE) macosX64("native") + if (HostManager.host == KonanTarget.MACOS_ARM64.INSTANCE) macosArm64("native") sourceSets { commonMain { diff --git a/plugin/build.gradle b/plugin/build.gradle deleted file mode 100644 index 3bdd1ccb..00000000 --- a/plugin/build.gradle +++ /dev/null @@ -1,132 +0,0 @@ -buildscript { - ext.kotlinDevUrl = rootProject.properties["kotlin_repo_url"] - repositories { - maven { url 'https://maven.pkg.jetbrains.space/kotlin/p/kotlinx/maven' } - mavenCentral() - if (kotlinDevUrl != null) { - maven { url = kotlinDevUrl } - } - } - dependencies { - classpath "kotlinx.team:kotlinx.team.infra:$infra_version" - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - } - -} - -plugins { - id 'java-gradle-plugin' - id 'maven-publish' - id 'com.gradle.plugin-publish' version '0.21.0' -} - -apply plugin: 'org.jetbrains.kotlin.jvm' -apply plugin: 'kotlinx.team.infra' - -infra { - teamcity { - libraryStagingRepoDescription = project.name - } - publishing { - include(":") - - libraryRepoUrl = "https://github.com/Kotlin/kotlinx-benchmark" - } -} - -logger.info("Using Kotlin $kotlin_version for project ${project.name}") - -repositories { - mavenCentral() - gradlePluginPortal() - - if (kotlinDevUrl != null) { - maven { url = kotlinDevUrl } - } -} - -pluginBundle { - website = 'https://github.com/Kotlin/kotlinx-benchmark' - vcsUrl = 'https://github.com/Kotlin/kotlinx-benchmark.git' - tags = ['benchmarking', 'multiplatform', 'kotlin'] -} - -gradlePlugin { - plugins { - benchmarkPlugin { - id = "org.jetbrains.kotlinx.benchmark" - implementationClass = "kotlinx.benchmark.gradle.BenchmarksPlugin" - displayName = "Gradle plugin for benchmarking" - description = "Toolkit for running benchmarks for multiplatform Kotlin code." - } - } -} - -sourceSets { - main { - kotlin.srcDirs = ['main/src'] - java.srcDirs = ['main/src'] - resources.srcDirs = ['main/resources'] - } - test { - kotlin.srcDirs = ['test/src'] - java.srcDirs = ['test/src'] - resources.srcDirs = ['test/resources'] - } -} - -compileKotlin { - kotlinOptions { - freeCompilerArgs += "-Xopt-in=kotlin.RequiresOptIn" - apiVersion = "1.4" // the version of Kotlin embedded in Gradle - } -} - -dependencies { - implementation group: 'org.jetbrains.kotlin', name: 'kotlin-reflect', version: kotlin_version - - implementation 'com.squareup:kotlinpoet:1.3.0' - - implementation group: 'org.jetbrains.kotlin', name: 'kotlin-util-klib-metadata', version: kotlin_version - implementation group: 'org.jetbrains.kotlin', name: 'kotlin-util-klib', version: kotlin_version - implementation group: 'org.jetbrains.kotlin', name: 'kotlin-util-io', version: kotlin_version - - compileOnly group: 'org.jetbrains.kotlin.multiplatform', name: 'org.jetbrains.kotlin.multiplatform.gradle.plugin', version: kotlin_version - compileOnly "org.jetbrains.kotlin:kotlin-compiler-embeddable:$kotlin_version" - compileOnly "org.openjdk.jmh:jmh-generator-bytecode:$jmhVersion" // used in worker -} - -tasks.register("overridePluginVersion") { - description = "Overrides BenchmarksPlugin.PLUGIN_VERSION during release builds" - onlyIf { - project.findProperty("releaseVersion") != null - } - doLast { - def benchmarksPluginFile = "${projectDir}/main/src/kotlinx/benchmark/gradle/BenchmarksPlugin.kt" - def releaseVersion = project.findProperty("releaseVersion") - ant.replaceregexp( - file: benchmarksPluginFile, - match: "const val PLUGIN_VERSION = \"[\\d.]+-SNAPSHOT\"", - replace: "const val PLUGIN_VERSION = \"$releaseVersion\"", - encoding: "UTF-8" - ) - } -} - -tasks.compileKotlin.dependsOn overridePluginVersion - -if (project.findProperty("publication_repository") == "space") { - // publish to Space repository - publishing { - repositories { - maven { - name = "space" - url = "https://maven.pkg.jetbrains.space/kotlin/p/kotlinx/dev" - credentials { - username = project.findProperty("space.user") - password = project.findProperty("space.token") - } - } - } - } -} diff --git a/plugin/build.gradle.kts b/plugin/build.gradle.kts new file mode 100644 index 00000000..331e98f8 --- /dev/null +++ b/plugin/build.gradle.kts @@ -0,0 +1,140 @@ +import kotlinx.team.infra.* + +val jmhVersion: String by project +val kotlin_version: String by project + +buildscript { + val kotlin_version: String by project + val infra_version: String by project + + repositories { + maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlinx/maven") + mavenCentral() + rootProject.properties["kotlin_repo_url"]?.let { + maven { url = uri(it.toString()) } + } + } + dependencies { + classpath("kotlinx.team:kotlinx.team.infra:$infra_version") + classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version") + } +} + +plugins { + `java-gradle-plugin` + `maven-publish` + id("com.gradle.plugin-publish") version "0.21.0" + kotlin("jvm") version "1.9.0" +} + +apply(plugin = "kotlinx.team.infra") + +configure { + teamcity { + libraryStagingRepoDescription = project.name + } + + publishing { + include(":") + + libraryRepoUrl = "https://github.com/Kotlin/kotlinx-benchmark" + } +} + +logger.info("Using Kotlin ${kotlin_version} for project ${project.name}") + +repositories { + mavenCentral() + gradlePluginPortal() + + rootProject.properties["kotlin_repo_url"]?.let { url -> + maven { setUrl(url.toString()) } + } +} + +pluginBundle { + website = "https://github.com/Kotlin/kotlinx-benchmark" + vcsUrl = "https://github.com/Kotlin/kotlinx-benchmark.git" + tags = listOf("benchmarking", "multiplatform", "kotlin") +} + +gradlePlugin { + plugins { + register("benchmarkPlugin") { + id = "org.jetbrains.kotlinx.benchmark" + implementationClass = "kotlinx.benchmark.gradle.BenchmarksPlugin" + displayName = "Gradle plugin for benchmarking" + description = "Toolkit for running benchmarks for multiplatform Kotlin code." + } + } +} + +sourceSets { + main { + kotlin.srcDir("main/src") + java.srcDir("main/src") + resources.srcDir("main/resources") + } + test { + kotlin.srcDir("test/src") + java.srcDir("test/src") + resources.srcDir("test/resources") + } +} + +tasks.withType().configureEach { + kotlinOptions { + freeCompilerArgs += "-opt-in=kotlin.RequiresOptIn" + apiVersion = "1.4" + } +} + +dependencies { + implementation("org.jetbrains.kotlin:kotlin-reflect:$kotlin_version") + implementation("com.squareup:kotlinpoet:1.3.0") + implementation("org.jetbrains.kotlin:kotlin-util-klib-metadata:$kotlin_version") + implementation("org.jetbrains.kotlin:kotlin-util-klib:$kotlin_version") + implementation("org.jetbrains.kotlin:kotlin-util-io:$kotlin_version") + compileOnly("org.jetbrains.kotlin.multiplatform:org.jetbrains.kotlin.multiplatform.gradle.plugin:$kotlin_version") + compileOnly("org.jetbrains.kotlin:kotlin-compiler-embeddable:$kotlin_version") + compileOnly("org.openjdk.jmh:jmh-generator-bytecode:$jmhVersion") +} + +tasks.register("overridePluginVersion") { + description = "Overrides BenchmarksPlugin.PLUGIN_VERSION during release builds" + onlyIf { + project.findProperty("releaseVersion") != null + } + doLast { + val benchmarksPluginFile = "${projectDir}/main/src/kotlinx/benchmark/gradle/BenchmarksPlugin.kt" + val releaseVersion = project.findProperty("releaseVersion") as String? + ant.withGroovyBuilder { + "replaceregexp"( + "file" to benchmarksPluginFile, + "match" to """const val PLUGIN_VERSION = "[\d.]+-SNAPSHOT"""", + "replace" to """const val PLUGIN_VERSION = "$releaseVersion"""", + "encoding" to "UTF-8" + ) + } + } +} + +tasks.named("compileKotlin").configure { + dependsOn("overridePluginVersion") +} + +if (project.findProperty("publication_repository") == "space") { + // publish to Space repository + publishing { + repositories { + maven { + name = "space" + url = uri("https://maven.pkg.jetbrains.space/kotlin/p/kotlinx/dev") + credentials { + username = project.findProperty("space.user") as String? + password = project.findProperty("space.token") as String? + } + } + } + } +} \ No newline at end of file diff --git a/plugin/gradle/wrapper/gradle-wrapper.properties b/plugin/gradle/wrapper/gradle-wrapper.properties index aa991fce..98debb84 100644 --- a/plugin/gradle/wrapper/gradle-wrapper.properties +++ b/plugin/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.2-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/plugin/main/src/kotlinx/benchmark/gradle/BenchmarksExtension.kt b/plugin/main/src/kotlinx/benchmark/gradle/BenchmarksExtension.kt index 44bc45a1..bb41416a 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/JsEngineExecTasks.kt b/plugin/main/src/kotlinx/benchmark/gradle/JsEngineExecTasks.kt index 0dd25755..be5bd5c7 100644 --- a/plugin/main/src/kotlinx/benchmark/gradle/JsEngineExecTasks.kt +++ b/plugin/main/src/kotlinx/benchmark/gradle/JsEngineExecTasks.kt @@ -45,7 +45,7 @@ private fun Project.getExecutableFile(compilation: KotlinJsCompilation): Provide val destinationDir = binary.linkSyncTask.map { it.destinationDir } destinationDir.zip(outputFile) { dir, file -> dir.resolve(file.name) } } - else -> compilation.compileKotlinTaskProvider.flatMap { it.outputFileProperty } + else -> compilation.compileTaskProvider.flatMap { it.outputFileProperty } } return project.layout.file(executableFile) } diff --git a/plugin/settings.gradle b/plugin/settings.gradle.kts similarity index 61% rename from plugin/settings.gradle rename to plugin/settings.gradle.kts index 6d2693ea..a85ae0c7 100644 --- a/plugin/settings.gradle +++ b/plugin/settings.gradle.kts @@ -3,4 +3,4 @@ pluginManagement { gradlePluginPortal() } } -rootProject.name = 'kotlinx-benchmark-plugin' +rootProject.name = "kotlinx-benchmark-plugin" diff --git a/runtime/build.gradle b/runtime/build.gradle.kts similarity index 66% rename from runtime/build.gradle rename to runtime/build.gradle.kts index 09f87d44..6377e5f8 100644 --- a/runtime/build.gradle +++ b/runtime/build.gradle.kts @@ -1,5 +1,5 @@ plugins { - id 'org.jetbrains.kotlin.multiplatform' + id("org.jetbrains.kotlin.multiplatform") } repositories { @@ -50,36 +50,42 @@ kotlin { wasm("wasmJs") { d8() } sourceSets.all { - kotlin.srcDirs = ["$it.name/src"] - resources.srcDirs = ["$it.name/resources"] - languageSettings { + val srcDirName = this.name + + kotlin.setSrcDirs(listOf("$srcDirName/src")) + resources.setSrcDirs(listOf("$srcDirName/resources")) + + languageSettings.apply { progressiveMode = true - optIn('kotlin.experimental.ExperimentalNativeApi') + optIn("kotlin.experimental.ExperimentalNativeApi") optIn("kotlinx.cinterop.ExperimentalForeignApi") } } sourceSets { - commonTest { + getByName("commonTest") { dependencies { - implementation 'org.jetbrains.kotlin:kotlin-test' + implementation("org.jetbrains.kotlin:kotlin-test") } } - jvmMain { + getByName("jvmMain") { dependencies { - compileOnly "org.openjdk.jmh:jmh-core:$jmhVersion" + compileOnly("org.openjdk.jmh:jmh-core:${property("jmhVersion")}") } } - jvmTest { + getByName("jvmTest") { dependencies { - implementation "org.openjdk.jmh:jmh-core:$jmhVersion" + implementation("org.openjdk.jmh:jmh-core:${property("jmhVersion")}") } } - jsMain { - jsIrMain.dependsOn(it) + + val jsMain by creating + + getByName("jsIrMain") { + dependsOn(jsMain) } - nativeMain { - dependsOn(commonMain) + getByName("nativeMain") { + dependsOn(commonMain.get()) } } } @@ -90,10 +96,10 @@ if (project.findProperty("publication_repository") == "space") { repositories { maven { name = "space" - url = "https://maven.pkg.jetbrains.space/kotlin/p/kotlinx/dev" + url = uri("https://maven.pkg.jetbrains.space/kotlin/p/kotlinx/dev") credentials { - username = project.findProperty("space.user") - password = project.findProperty("space.token") + username = project.findProperty("space.user") as String? + password = project.findProperty("space.token") as String? } } } diff --git a/settings.gradle b/settings.gradle deleted file mode 100644 index eb693a94..00000000 --- a/settings.gradle +++ /dev/null @@ -1,23 +0,0 @@ -pluginManagement { - repositories { - gradlePluginPortal() - if (settings.hasProperty("kotlin_repo_url") && settings.kotlin_repo_url != null) { - maven { url = settings.kotlin_repo_url } - } - } -} - -rootProject.name = 'kotlinx-benchmark' - -includeBuild("plugin") - -include "runtime" -project(":runtime").name = 'kotlinx-benchmark-runtime' - -include "integration" - -include "examples" -include "examples:kotlin-multiplatform" -include "examples:java" -include "examples:kotlin" -include "examples:kotlin-kts" diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 00000000..e6c4b85f --- /dev/null +++ b/settings.gradle.kts @@ -0,0 +1,23 @@ +pluginManagement { + repositories { + gradlePluginPortal() + val kotlin_repo_url: String? by settings + kotlin_repo_url?.takeIf { it.isNotEmpty() }?.let { repoUrl -> + maven { url = uri(repoUrl) } + } + } +} + +rootProject.name = "kotlinx-benchmark" + +includeBuild("plugin") + +include("runtime") +project(":runtime").name = "kotlinx-benchmark-runtime" + +include("integration") + +include("examples") +include("examples:kotlin-multiplatform") +include("examples:java") +include("examples:kotlin-kts")