xref: /aosp_15_r20/external/kotlinx.coroutines/benchmarks/build.gradle.kts (revision 7a7160fed73afa6648ef8aa100d4a336fe921d9a)
1*7a7160feSAndroid Build Coastguard Worker @file:Suppress("UnstableApiUsage")
2*7a7160feSAndroid Build Coastguard Worker 
3*7a7160feSAndroid Build Coastguard Worker import org.jetbrains.kotlin.gradle.tasks.*
4*7a7160feSAndroid Build Coastguard Worker import org.jetbrains.kotlin.gradle.dsl.JvmTarget
5*7a7160feSAndroid Build Coastguard Worker 
<lambda>null6*7a7160feSAndroid Build Coastguard Worker plugins {
7*7a7160feSAndroid Build Coastguard Worker     id("com.github.johnrengelman.shadow")
8*7a7160feSAndroid Build Coastguard Worker     id("me.champeau.jmh")
9*7a7160feSAndroid Build Coastguard Worker }
10*7a7160feSAndroid Build Coastguard Worker 
<lambda>null11*7a7160feSAndroid Build Coastguard Worker repositories {
12*7a7160feSAndroid Build Coastguard Worker     maven("https://repo.typesafe.com/typesafe/releases/")
13*7a7160feSAndroid Build Coastguard Worker }
14*7a7160feSAndroid Build Coastguard Worker 
<lambda>null15*7a7160feSAndroid Build Coastguard Worker java {
16*7a7160feSAndroid Build Coastguard Worker     sourceCompatibility = JavaVersion.VERSION_1_8
17*7a7160feSAndroid Build Coastguard Worker     targetCompatibility = JavaVersion.VERSION_1_8
18*7a7160feSAndroid Build Coastguard Worker }
19*7a7160feSAndroid Build Coastguard Worker 
<lambda>null20*7a7160feSAndroid Build Coastguard Worker tasks.named<KotlinCompile>("compileJmhKotlin") {
21*7a7160feSAndroid Build Coastguard Worker     compilerOptions {
22*7a7160feSAndroid Build Coastguard Worker         jvmTarget = JvmTarget.JVM_1_8
23*7a7160feSAndroid Build Coastguard Worker         freeCompilerArgs.add("-Xjvm-default=all")
24*7a7160feSAndroid Build Coastguard Worker     }
25*7a7160feSAndroid Build Coastguard Worker }
26*7a7160feSAndroid Build Coastguard Worker 
<lambda>null27*7a7160feSAndroid Build Coastguard Worker val jmhJarTask = tasks.named<Jar>("jmhJar") {
28*7a7160feSAndroid Build Coastguard Worker     archiveBaseName = "benchmarks"
29*7a7160feSAndroid Build Coastguard Worker     archiveClassifier = null
30*7a7160feSAndroid Build Coastguard Worker     archiveVersion = null
31*7a7160feSAndroid Build Coastguard Worker     archiveVersion.convention(null as String?)
32*7a7160feSAndroid Build Coastguard Worker     destinationDirectory = rootDir
33*7a7160feSAndroid Build Coastguard Worker }
34*7a7160feSAndroid Build Coastguard Worker 
<lambda>null35*7a7160feSAndroid Build Coastguard Worker tasks {
36*7a7160feSAndroid Build Coastguard Worker     // For some reason the DuplicatesStrategy from jmh is not enough
37*7a7160feSAndroid Build Coastguard Worker     // and errors with duplicates appear unless I force it to WARN only:
38*7a7160feSAndroid Build Coastguard Worker     withType<Copy> {
39*7a7160feSAndroid Build Coastguard Worker         duplicatesStrategy = DuplicatesStrategy.WARN
40*7a7160feSAndroid Build Coastguard Worker     }
41*7a7160feSAndroid Build Coastguard Worker 
42*7a7160feSAndroid Build Coastguard Worker     build {
43*7a7160feSAndroid Build Coastguard Worker         dependsOn(jmhJarTask)
44*7a7160feSAndroid Build Coastguard Worker     }
45*7a7160feSAndroid Build Coastguard Worker }
46*7a7160feSAndroid Build Coastguard Worker 
<lambda>null47*7a7160feSAndroid Build Coastguard Worker dependencies {
48*7a7160feSAndroid Build Coastguard Worker     implementation("org.openjdk.jmh:jmh-core:1.35")
49*7a7160feSAndroid Build Coastguard Worker     implementation("io.projectreactor:reactor-core:${version("reactor")}")
50*7a7160feSAndroid Build Coastguard Worker     implementation("io.reactivex.rxjava2:rxjava:2.1.9")
51*7a7160feSAndroid Build Coastguard Worker     implementation("com.github.akarnokd:rxjava2-extensions:0.20.8")
52*7a7160feSAndroid Build Coastguard Worker 
53*7a7160feSAndroid Build Coastguard Worker     implementation("com.typesafe.akka:akka-actor_2.12:2.5.0")
54*7a7160feSAndroid Build Coastguard Worker     implementation(project(":kotlinx-coroutines-core"))
55*7a7160feSAndroid Build Coastguard Worker     implementation(project(":kotlinx-coroutines-debug"))
56*7a7160feSAndroid Build Coastguard Worker     implementation(project(":kotlinx-coroutines-reactive"))
57*7a7160feSAndroid Build Coastguard Worker 
58*7a7160feSAndroid Build Coastguard Worker     // add jmh dependency on main
59*7a7160feSAndroid Build Coastguard Worker     "jmhImplementation"(sourceSets.main.get().runtimeClasspath)
60*7a7160feSAndroid Build Coastguard Worker }
61