[Build] Migrate most of the build logic from Project.buildDir usage

It's going to be deprecated in Gradle 8.3

There's currently no way to pass a `org.gradle.api.provider.Provider` to the JavaExec.systemProperty or Test.systemProperty. There's a workaround using `org.gradle.process.CommandLineArgumentProvider`, but I intentionally don't rework these calls as Gradle is going to allow passing providers to configure system properties: https://github.com/gradle/gradle/issues/12247#issuecomment-1568427242
^KTI-1473 In Progress
This commit is contained in:
Alexander.Likhachev
2023-10-11 22:42:51 +02:00
committed by Space Team
parent b784544f8d
commit a19bd2ed2e
69 changed files with 328 additions and 306 deletions
+16 -7
View File
@@ -73,7 +73,7 @@ tasks.withType<Zip>().matching { it.name == "mainBenchmarkJar" }.configureEach {
val benchmarkTasks = listOf("mainBenchmark", "mainFirBenchmark", "mainNiBenchmark")
tasks.withType<JavaExec>().matching { it.name in benchmarkTasks }.configureEach {
dependsOn(":createIdeaHomeForTests")
systemProperty("idea.home.path", ideaHomePathForTests().canonicalPath)
systemProperty("idea.home.path", ideaHomePathForTests().get().asFile.canonicalPath)
systemProperty("idea.use.native.fs.for.win", false)
}
@@ -81,17 +81,26 @@ tasks.register<JavaExec>("runBenchmark") {
dependsOn(":createIdeaHomeForTests")
// jmhArgs example: -PjmhArgs='CommonCalls -p size=500 -p isIR=true -p useNI=true -f 1'
val jmhArgs = if (project.hasProperty("jmhArgs")) project.property("jmhArgs").toString() else ""
val resultFilePath = "$buildDir/benchmarks/jmh-result.json"
val ideaHome = ideaHomePathForTests().canonicalPath
val jmhArgs = project.providers.gradleProperty("jvmArgs")
val resultFilePath = project.layout.buildDirectory.file("benchmarks/jmh-result.json")
val ideaHome = ideaHomePathForTests()
val benchmarkJarPath = "$buildDir/benchmarks/main/jars/benchmarks.jar"
args = mutableListOf("-Didea.home.path=$ideaHome", benchmarkJarPath, "-rf", "json", "-rff", resultFilePath) + jmhArgs.split("\\s".toRegex())
val benchmarkJarPath = project.layout.buildDirectory.file("benchmarks/main/jars/benchmarks.jar")
argumentProviders.add {
listOf(
"-Didea.home.path=${ideaHome.get().asFile.canonicalPath}",
benchmarkJarPath.get().asFile.toString(),
"-rf",
"json",
"-rff",
resultFilePath.get().asFile.toString(),
) + jmhArgs.map { it.split("\\s".toRegex()) }.orElse(emptyList()).get()
}
mainClass.set("-jar")
doLast {
if (project.kotlinBuildProperties.isTeamcityBuild) {
val jsonArray = com.google.gson.JsonParser.parseString(File(resultFilePath).readText()).asJsonArray
val jsonArray = com.google.gson.JsonParser.parseString(resultFilePath.get().asFile.readText()).asJsonArray
jsonArray.forEach {
val benchmark = it.asJsonObject
// remove unnecessary name parts from string like this "org.jetbrains.kotlin.benchmarks.CommonCallsBenchmark.benchmark"