Skip to content

Commit 211c310

Browse files
Abduqodiri Qurbonzodaqurbonzoda
authored andcommitted
Override BenchmarksPlugin.PLUGIN_VERSION during release builds
1 parent 9f4e990 commit 211c310

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

plugin/build.gradle

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,24 @@ dependencies {
9696
compileOnly "org.openjdk.jmh:jmh-generator-bytecode:$jmhVersion" // used in worker
9797
}
9898

99+
tasks.register("overridePluginVersion") {
100+
description = "Overrides BenchmarksPlugin.PLUGIN_VERSION during release builds"
101+
onlyIf {
102+
project.findProperty("releaseVersion") != null
103+
}
104+
doLast {
105+
def benchmarksPluginFile = "${projectDir}/main/src/kotlinx/benchmark/gradle/BenchmarksPlugin.kt"
106+
def releaseVersion = project.findProperty("releaseVersion")
107+
ant.replaceregexp(
108+
file: benchmarksPluginFile,
109+
match: "const val PLUGIN_VERSION = \"[\\d.]+-SNAPSHOT\"",
110+
replace: "const val PLUGIN_VERSION = \"$releaseVersion\"",
111+
encoding: "UTF-8"
112+
)
113+
}
114+
}
115+
116+
tasks.compileKotlin.dependsOn overridePluginVersion
99117

100118
if (project.findProperty("publication_repository") == "space") {
101119
// publish to Space repository

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import org.gradle.util.*
77
class BenchmarksPlugin : Plugin<Project> {
88
companion object {
99
const val PLUGIN_ID = "org.jetbrains.kotlinx.benchmark"
10+
// This value is overridden by `overridePluginVersion` task during release builds.
1011
const val PLUGIN_VERSION = "0.5.0-SNAPSHOT"
1112

1213
const val BENCHMARKS_TASK_GROUP = "benchmark"

0 commit comments

Comments
 (0)