[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
+7 -5
View File
@@ -2,23 +2,25 @@
import java.io.File
val buildVersionFilePath = "$buildDir/build.txt"
val buildVersionFilePath = layout.buildDirectory.file("build.txt")
val buildVersion by configurations.creating
val buildNumber: String by rootProject.extra
val kotlinVersion: String by rootProject.extra
val writeBuildNumber by tasks.registering {
val versionFile = File(buildVersionFilePath)
val versionFile = buildVersionFilePath
val buildNumber = buildNumber
inputs.property("version", buildNumber)
outputs.file(versionFile)
doLast {
versionFile.parentFile.mkdirs()
versionFile.writeText(buildNumber)
with(versionFile.get().asFile) {
parentFile.mkdirs()
writeText(buildNumber)
}
}
}
artifacts.add(buildVersion.name, file(buildVersionFilePath)) {
artifacts.add(buildVersion.name, buildVersionFilePath) {
builtBy(writeBuildNumber)
}
+3 -5
View File
@@ -80,8 +80,6 @@ val buildNumber by configurations.creating
val compilerBaseName = name
val outputJar = fileFrom(buildDir, "libs", "$compilerBaseName.jar")
val compilerModules: Array<String> by rootProject.extra
val distLibraryProjects = listOfNotNull(
@@ -261,7 +259,7 @@ val distSbomTask = configureSbom(
val packCompiler by task<Jar> {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
destinationDirectory.set(File(buildDir, "libs"))
destinationDirectory.set(layout.buildDirectory.dir("libs"))
archiveClassifier.set("before-proguard")
dependsOn(fatJarContents)
@@ -315,7 +313,7 @@ val proguard by task<CacheableProguardTask> {
provider { packCompiler.get().outputs.files.singleFile }
)
outjars(fileFrom(buildDir, "libs", "$compilerBaseName-after-proguard.jar"))
outjars(layout.buildDirectory.file("libs/$compilerBaseName-after-proguard.jar"))
libraryjars(mapOf("filter" to "!META-INF/versions/**"), proguardLibraries)
libraryjars(
@@ -340,7 +338,7 @@ val proguard by task<CacheableProguardTask> {
)
)
printconfiguration("$buildDir/compiler.pro.dump")
printconfiguration(layout.buildDirectory.file("compiler.pro.dump"))
}
val pack = if (kotlinBuildProperties.proguard) proguard else packCompiler
@@ -44,7 +44,7 @@ idePluginDependency {
val shadowJar by task<ShadowJar> {
configurations = listOf(embedded)
duplicatesStrategy = DuplicatesStrategy.FAIL
destinationDirectory.set(File(buildDir, "libs"))
destinationDirectory.set(layout.buildDirectory.dir("libs"))
archiveClassifier.set("shadow")
}
@@ -53,7 +53,7 @@ idePluginDependency {
configuration(fileFrom(projectDir, "backend-native-for-ide.pro"))
injars(mapOf("filter" to "!META-INF/versions/**"), shadowJar.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))