[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
@@ -180,7 +180,7 @@ abstract class BenchmarkingPlugin: Plugin<Project> {
protected open fun Project.configureNativeTask(nativeTarget: KotlinNativeTarget): Task {
val konanRun = createRunTask(this, "konanRun", nativeLinkTask,
nativeExecutable, buildDir.resolve(nativeBenchResults).absolutePath).apply {
nativeExecutable, layout.buildDirectory.file(nativeBenchResults).get().asFile.absolutePath).apply {
group = BENCHMARKING_GROUP
description = "Runs the benchmark for Kotlin/Native."
}
@@ -222,7 +222,7 @@ abstract class BenchmarkingPlugin: Plugin<Project> {
doLast {
val applicationName = benchmark.applicationName
val benchContents = buildDir.resolve(nativeBenchResults).readText()
val benchContents = layout.buildDirectory.file(nativeBenchResults).get().asFile.readText()
val nativeCompileTasks = if (benchmark.compileTasks.isEmpty()) {
listOf("linkBenchmark${benchmark.buildType.name.lowercase().replaceFirstChar { it.uppercase() }}ExecutableNative")
} else benchmark.compileTasks
@@ -239,7 +239,7 @@ abstract class BenchmarkingPlugin: Plugin<Project> {
)
val output = createJsonReport(properties)
buildDir.resolve(nativeJson).writeText(output)
layout.buildDirectory.file(nativeJson).get().asFile.writeText(output)
}
}
}
@@ -40,11 +40,11 @@ open class CompileBenchmarkingPlugin : Plugin<Project> {
private fun Project.configureUtilityTasks() {
tasks.create("configureBuild") {
doLast { mkdir(buildDir) }
doLast { mkdir(layout.buildDirectory.get().asFile) }
}
tasks.create("clean", Delete::class.java) {
delete(buildDir)
delete(layout.buildDirectory)
}
}
@@ -90,7 +90,7 @@ open class CompileBenchmarkingPlugin : Plugin<Project> {
repeatNumber,
exitCodes
)
val nativeExecutable = buildDir.resolve("program${getNativeProgramExtension()}")
val nativeExecutable = layout.buildDirectory.file("program${getNativeProgramExtension()}").get().asFile
val properties = commonBenchmarkProperties + mapOf(
"type" to "native",
"compilerVersion" to konanVersion,
@@ -100,7 +100,7 @@ open class CompileBenchmarkingPlugin : Plugin<Project> {
"codeSize" to getCodeSizeBenchmark(applicationName, nativeExecutable.absolutePath)
)
val output = createJsonReport(properties)
buildDir.resolve(nativeJson).writeText(output)
layout.buildDirectory.file(nativeJson).get().asFile.writeText(output)
}
konanRun.finalizedBy(this)
}
@@ -44,7 +44,7 @@ open class KotlinNativeBenchmarkingPlugin: BenchmarkingPlugin() {
val applicationName = benchmark.applicationName
val jarPath = (tasks.getByName("jvmJar") as Jar).archiveFile.get().asFile
val jvmCompileTime = getJvmCompileTime(project, applicationName)
val benchContents = buildDir.resolve(jvmBenchResults).readText()
val benchContents = layout.buildDirectory.file(jvmBenchResults).get().asFile.readText()
val properties: Map<String, Any> = commonBenchmarkProperties + mapOf(
"type" to "jvm",
@@ -55,7 +55,7 @@ open class KotlinNativeBenchmarkingPlugin: BenchmarkingPlugin() {
)
val output = createJsonReport(properties)
buildDir.resolve(jvmJson).writeText(output)
layout.buildDirectory.file(jvmJson).get().asFile.writeText(output)
}
jvmRun.finalizedBy(this)
@@ -78,7 +78,7 @@ open class KotlinNativeBenchmarkingPlugin: BenchmarkingPlugin() {
args("-p", "${benchmark.applicationName}::")
warmupCount = jvmWarmup
repeatCount = attempts
outputFileName = buildDir.resolve(jvmBenchResults).absolutePath
outputFileName = layout.buildDirectory.file(jvmBenchResults).get().asFile.absolutePath
repeatingType = benchmark.repeatingType
}
}
@@ -53,7 +53,7 @@ open class SwiftBenchmarkingPlugin : BenchmarkingPlugin() {
override val benchmarkExtensionName: String = "swiftBenchmark"
override val Project.nativeExecutable: String
get() = Paths.get(buildDir.absolutePath, benchmark.applicationName).toString()
get() = Paths.get(layout.buildDirectory.get().asFile.absolutePath, benchmark.applicationName).toString()
override val Project.nativeLinkTask: Task
get() = tasks.getByName("buildSwift")
@@ -92,7 +92,7 @@ open class SwiftBenchmarkingPlugin : BenchmarkingPlugin() {
val frameworkParentDirPath = framework.outputDirectory.absolutePath
val options = listOf("-O", "-wmo", "-Xlinker", "-rpath", "-Xlinker", frameworkParentDirPath, "-F", frameworkParentDirPath)
compileSwift(project, nativeTarget.konanTarget, benchmark.swiftSources, options,
Paths.get(buildDir.absolutePath, benchmark.applicationName), false)
Paths.get(layout.buildDirectory.get().asFile.absolutePath, benchmark.applicationName), false)
}
}
}