Skip to content

Commit 6428a59

Browse files
author
Abduqodiri Qurbonzoda
committed
[Plugin] Fix search of the benchmark compilation of a multiplatform target
MPP plugin has added "Compilation" postfix to configuration names of compilations. See KT-35916.
1 parent 4200066 commit 6428a59

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

plugin/main/src/kotlinx/benchmark/gradle/BenchmarksExtension.kt

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import groovy.lang.*
44
import org.gradle.api.*
55
import org.gradle.api.plugins.*
66
import org.jetbrains.kotlin.gradle.dsl.*
7+
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation
78
import org.jetbrains.kotlin.gradle.plugin.mpp.*
89

910
fun Project.benchmark(configure: Action<BenchmarksExtension>) {
@@ -47,9 +48,8 @@ open class BenchmarksExtension(val project: Project) {
4748

4849
when {
4950
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)) {
5353
null -> {
5454
project.logger.warn("Warning: Cannot find a benchmark compilation '$name', ignoring.")
5555
BenchmarkTarget(this, name) // ignore
@@ -71,8 +71,7 @@ open class BenchmarksExtension(val project: Project) {
7171

7272
}
7373
javaExtension != null -> {
74-
val sourceSet = javaExtension.sourceSets.findByName(name)
75-
when (sourceSet) {
74+
when (val sourceSet = javaExtension.sourceSets.findByName(name)) {
7675
null -> {
7776
project.logger.warn("Warning: Cannot find a benchmark sourceSet '$name', ignoring.")
7877
BenchmarkTarget(this, name) // ignore

0 commit comments

Comments
 (0)