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

Use kts build script in example projects & update with latest dsl #136

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
49 changes: 0 additions & 49 deletions build.gradle

This file was deleted.

57 changes: 57 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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<InfraExtension> {
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)
}
}
4 changes: 0 additions & 4 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,4 @@ plugins {

repositories {
mavenCentral()
}

kotlinDslPluginOptions {
experimentalWarning.set(false)
}
8 changes: 0 additions & 8 deletions examples/build.gradle

This file was deleted.

8 changes: 8 additions & 0 deletions examples/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
group "org.jetbrains.kotlinx.benchmark.examples"
version "0.1-SNAPSHOT"

subprojects {
repositories {
mavenCentral()
}
}
14 changes: 8 additions & 6 deletions examples/java/build.gradle → examples/java/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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")
Expand All @@ -29,6 +30,7 @@ benchmark {
}
targets {
register("main") {
this as JvmBenchmarkTarget
jmhVersion = "1.21"
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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?
Expand All @@ -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 {
Expand All @@ -32,39 +33,45 @@ 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"))
}
}
}

// Configure benchmark
benchmark {
configurations {
main { // --> jvmBenchmark, jsBenchmark, <native target>Benchmark, benchmark
named("main") { // --> jvmBenchmark, jsBenchmark, <native target>Benchmark, benchmark
iterations = 5 // number of iterations
iterationTime = 300
iterationTimeUnit = "ms"
advanced("jvmForks", 3)
advanced("jsUseBridge", true)
}

params {
create("params") {
iterations = 5 // number of iterations
iterationTime = 300
iterationTimeUnit = "ms"
Expand All @@ -73,7 +80,7 @@ benchmark {
param("unused", 6, 9)
}

fast { // --> jvmFastBenchmark, jsFastBenchmark, <native target>FastBenchmark, fastBenchmark
create("fast") { // --> jvmFastBenchmark, jsFastBenchmark, <native target>FastBenchmark, fastBenchmark
include("Common")
exclude("long")
iterations = 5
Expand All @@ -82,7 +89,7 @@ benchmark {
advanced("nativeGCAfterIteration", true)
}

csv {
create("csv") {
include("Common")
exclude("long")
iterations = 1
Expand All @@ -91,7 +98,7 @@ benchmark {
reportFormat = "csv" // csv report format
}

fork {
create("fork") {
include("CommonBenchmark")
iterations = 5
iterationTime = 300
Expand All @@ -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")
Expand Down
28 changes: 0 additions & 28 deletions examples/kotlin/benchmarks/src/TestBenchmark.kt

This file was deleted.

Loading