@@ -4,6 +4,7 @@ import groovy.lang.*
4
4
import org.gradle.api.*
5
5
import org.gradle.api.plugins.*
6
6
import org.jetbrains.kotlin.gradle.dsl.*
7
+ import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation
7
8
import org.jetbrains.kotlin.gradle.plugin.mpp.*
8
9
9
10
fun Project.benchmark (configure : Action <BenchmarksExtension >) {
@@ -47,9 +48,8 @@ open class BenchmarksExtension(val project: Project) {
47
48
48
49
when {
49
50
multiplatform != null -> {
50
- val compilations = multiplatform.targets.flatMap { it.compilations }
51
- val compilation = compilations.singleOrNull { it.apiConfigurationName.removeSuffix(" Api" ) == name }
52
- when (compilation) {
51
+ val target = multiplatform.targets.findByName(name)
52
+ when (val compilation = target?.compilations?.findByName(KotlinCompilation .MAIN_COMPILATION_NAME )) {
53
53
null -> {
54
54
project.logger.warn(" Warning: Cannot find a benchmark compilation '$name ', ignoring." )
55
55
BenchmarkTarget (this , name) // ignore
@@ -71,8 +71,7 @@ open class BenchmarksExtension(val project: Project) {
71
71
72
72
}
73
73
javaExtension != null -> {
74
- val sourceSet = javaExtension.sourceSets.findByName(name)
75
- when (sourceSet) {
74
+ when (val sourceSet = javaExtension.sourceSets.findByName(name)) {
76
75
null -> {
77
76
project.logger.warn(" Warning: Cannot find a benchmark sourceSet '$name ', ignoring." )
78
77
BenchmarkTarget (this , name) // ignore
0 commit comments