From c18b0f23bd9d9093d490fee537681a6fde15f199 Mon Sep 17 00:00:00 2001 From: "Kenneth J. Shackleton" Date: Mon, 3 Jun 2024 10:53:02 +0100 Subject: [PATCH] Accept an include filter in the JMH plugin. Signed-off-by: Kenneth J. Shackleton --- buildSrc/src/main/kotlin/JmhPlugin.kt | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/buildSrc/src/main/kotlin/JmhPlugin.kt b/buildSrc/src/main/kotlin/JmhPlugin.kt index 5c7ac24cbf..dd66ae8dbd 100644 --- a/buildSrc/src/main/kotlin/JmhPlugin.kt +++ b/buildSrc/src/main/kotlin/JmhPlugin.kt @@ -19,6 +19,7 @@ import org.gradle.api.Project import org.gradle.api.tasks.JavaExec import org.gradle.api.tasks.SourceSetContainer import org.gradle.kotlin.dsl.get +import org.gradle.kotlin.dsl.register class JmhPlugin : Plugin { override fun apply(target: Project): Unit = target.run { @@ -35,15 +36,18 @@ class JmhPlugin : Plugin { add(name, "org.openjdk.jmh:jmh-generator-annprocess:${Versions.JMH}") } } - tasks.register("jmh", JavaExec::class.java) { + tasks.register("jmh") { val reportDir = layout.buildDirectory.dir("reports/jmh") val reportFile = layout.buildDirectory.file("reports/jmh/jmh.json") group = "benchmark" dependsOn("jmhClasses") mainClass.set("org.openjdk.jmh.Main") args( - "-rf", "json", - "-rff", reportFile.get().asFile.absolutePath + listOfNotNull( + properties["jmh.include"]?.toString(), + "-rf", "json", + "-rff", reportFile.get().asFile.absolutePath + ) ) classpath(sourceSets.getByName("jmh").runtimeClasspath) doFirst { reportDir.get().asFile.mkdir() }