[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
@@ -68,7 +68,7 @@ val mavenPackagesToRelocate = listOf(
val relocatedJar by task<ShadowJar> {
configurations = listOf(embedded)
duplicatesStrategy = DuplicatesStrategy.INCLUDE
destinationDirectory.set(File(buildDir, "libs"))
destinationDirectory.set(layout.buildDirectory.dir("libs"))
archiveClassifier.set("relocated")
transform(ComponentsXmlResourceTransformer())
@@ -82,8 +82,7 @@ val relocatedJar by task<ShadowJar> {
val normalizeComponentsXmlEndings by tasks.registering {
dependsOn(relocatedJar)
val outputDirectory = buildDir.resolve(name)
val outputFile = outputDirectory.resolve(ComponentsXmlResourceTransformer.COMPONENTS_XML_PATH)
val outputFile = layout.buildDirectory.file("$name/${ComponentsXmlResourceTransformer.COMPONENTS_XML_PATH}")
val relocatedJarFile = project.provider { relocatedJar.get().singleOutputFile() }
val archiveOperations = serviceOf<ArchiveOperations>()
outputs.file(outputFile)
@@ -93,8 +92,9 @@ val normalizeComponentsXmlEndings by tasks.registering {
include { it.path == ComponentsXmlResourceTransformer.COMPONENTS_XML_PATH }
}.single().readText()
val processedComponentsXml = componentsXml.replace("\r\n", "\n")
outputDirectory.mkdirs()
outputFile.writeText(processedComponentsXml)
val outputAsFile = outputFile.get().asFile
outputAsFile.parentFile.mkdirs()
outputAsFile.writeText(processedComponentsXml)
}
}
@@ -123,7 +123,7 @@ val proguard by task<CacheableProguardTask> {
injars(mapOf("filter" to "!META-INF/versions/**,!kotlinx/coroutines/debug/**"), normalizedJar.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))