[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
@@ -25,7 +25,7 @@ dependencies {
signature("org.codehaus.mojo.signature:java16:1.1@signature")
}
val signaturesDirectory = buildDir.resolve("signatures")
val signaturesDirectory = layout.buildDirectory.get().asFile.resolve("signatures")
val collectSignatures by tasks.registering(Sync::class) {
from(signature)
@@ -64,7 +64,7 @@ val outgoingClasspath by configurations.creating {
}
tasks.register<Delete>("clean") {
delete(project.buildDir)
delete(layout.buildDirectory)
}
//endregion
@@ -94,11 +94,12 @@ run {
implicitDependencies("com.google.protobuf:protoc:3.21.9:windows-x86_64@exe")
}
val protocExecutable = buildDir.resolve("protoc/bin")
val protocExecutable = layout.buildDirectory.file("protoc/bin")
val setupProtoc = tasks.register("setupProtoc") {
doFirst {
protoc.files.single().copyTo(protocExecutable, overwrite = true)
protocExecutable.setExecutable(true)
val protocFile = protocExecutable.get().asFile
protoc.files.single().copyTo(protocFile, overwrite = true)
protocFile.setExecutable(true)
}
}
@@ -122,16 +123,16 @@ run {
workingDir(project.projectDir)
commandLine(
*arrayOf(
protocExecutable.absolutePath,
argumentProviders.add {
listOf(
protocExecutable.get().asFile.absolutePath,
"-I=$protoSources",
"--java_out=${javaOutput.absolutePath}",
"--kotlin_out=${kotlinOutput.absolutePath}"
) + protoSources.listFiles().orEmpty()
.filter { it.extension == "proto" }
.map { it.path },
)
.map { it.path }
}
}
}
@@ -126,7 +126,7 @@ val cleanTestKitCacheTask = tasks.register<Delete>("cleanTestKitCache") {
group = "Build"
description = "Deletes temporary Gradle TestKit cache"
delete(project.buildDir.resolve("testKitCache"))
delete(layout.buildDirectory.dir("testKitCache"))
}
tasks.register<Delete>("cleanUserHomeKonanDir") {
@@ -7,7 +7,7 @@ plugins {
}
repositories {
maven(project(":producer").buildDir.resolve("repo"))
maven(project(":producer").layout.buildDirectory.dir("repo"))
mavenLocal()
mavenCentral()
}
@@ -68,7 +68,7 @@ noDefaultJar()
val relocatedJar by task<ShadowJar> {
configurations = listOf(relocatedJarContents)
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
destinationDirectory.set(File(buildDir, "libs"))
destinationDirectory.set(layout.buildDirectory.dir("libs"))
archiveClassifier.set("before-proguard")
// don't add this files to resources classpath to avoid IDE exceptions on kotlin project
@@ -87,7 +87,7 @@ val proguard by task<CacheableProguardTask> {
injars(mapOf("filter" to "!META-INF/versions/**,!kotlinx/coroutines/debug/**"), relocatedJar.get().outputs.files)
outjars(fileFrom(buildDir, "libs", "$jarBaseName-$version-after-proguard.jar"))
outjars(layout.buildDirectory.file("libs/$jarBaseName-$version-after-proguard.jar"))
javaLauncher.set(project.getToolchainLauncherFor(JdkMajorVersion.JDK_1_8))