[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
@@ -146,15 +146,15 @@ class NamedNativeInteropConfig implements Named {
}
File getNativeLibsDir() {
return new File(project.buildDir, "nativelibs/$target")
return project.layout.buildDirectory.dir("nativelibs/$target").get().asFile
}
File getGeneratedSrcDir() {
return new File(project.buildDir, "nativeInteropStubs/$name/kotlin")
return project.layout.buildDirectory.dir("nativeInteropStubs/$name/kotlin").get().asFile
}
File getTemporaryFilesDir() {
return new File(project.buildDir, "interopTemp")
return project.layout.buildDirectory.dir("interopTemp").get().asFile
}
String getLlvmDir() {
@@ -213,8 +213,8 @@ class NamedNativeInteropConfig implements Named {
jvmArgs '-ea'
systemProperties "java.library.path" : project.files(
new File(project.findProject(":kotlin-native:Interop:Indexer").buildDir, "nativelibs"),
new File(project.findProject(":kotlin-native:Interop:Runtime").buildDir, "nativelibs")
project.findProject(":kotlin-native:Interop:Indexer").layout.buildDirectory.dir("nativelibs"),
project.findProject(":kotlin-native:Interop:Runtime").layout.buildDirectory.dir("nativelibs"),
).asPath
// Set the konan.home property because we run the cinterop tool not from a distribution jar
// so it will not be able to determine this path by itself.
@@ -16,7 +16,7 @@ open class CopyCommonSources : DefaultTask() {
val sourcePaths: ConfigurableFileCollection = project.files()
@OutputDirectory
var outputDir: File = project.buildDir.resolve("sources")
var outputDir: File = project.layout.buildDirectory.get().asFile.resolve("sources")
fun zipSources(needToZip: Boolean) {
zipSources = needToZip
@@ -46,7 +46,7 @@ open class CopyCommonSources : DefaultTask() {
val filePrefix = sourcePath.name.replace(Regex("-\\d+.*"), "")
val targetFileName = "$filePrefix-sources.zip"
val tempDir = project.buildDir.resolve(name).resolve(filePrefix).also {
val tempDir = project.layout.buildDirectory.dir("$name/$filePrefix").get().asFile.also {
it.deleteRecursively()
it.mkdirs()
}
@@ -89,7 +89,7 @@ internal val Project.konanVersion: String
?.toString()
?: project.version.toString()
internal val Project.konanBuildRoot get() = buildDir.resolve("konan")
internal val Project.konanBuildRoot get() = layout.buildDirectory.get().asFile.resolve("konan")
internal val Project.konanBinBaseDir get() = konanBuildRoot.resolve("bin")
internal val Project.konanLibsBaseDir get() = konanBuildRoot.resolve("libs")
internal val Project.konanBitcodeBaseDir get() = konanBuildRoot.resolve("bitcode")
@@ -92,7 +92,7 @@ abstract class KonanCompileTask: KonanBuildingTask(), KonanCompileSpec {
protected fun directoryToKt(dir: Any) = project.fileTree(dir).apply {
include("**/*.kt")
exclude { it.file.startsWith(project.buildDir) }
exclude { it.file.startsWith(project.layout.buildDirectory.get().asFile) }
}
// Command line ------------------------------------------------------------
@@ -121,7 +121,7 @@ open class SourceSet(
return SourceSet(
sourceSets,
name,
sourceSets.project.file("${sourceSets.project.buildDir}/$name/${suffixes.first}_${suffixes.second}/"),
sourceSets.project.file(sourceSets.project.layout.buildDirectory.dir("$name/${suffixes.first}_${suffixes.second}/")),
this,
suffixes
)
@@ -218,7 +218,7 @@ open class NativeToolsExtension(val project: Project) {
dependsOn(it.implicitTasks())
}
val deps = objSet.flatMap { it.collection.files }.map { it.path }
val toolConfiguration = ToolPatternImpl(sourceSets.extension, "${project.buildDir.path}/$name", *deps.toTypedArray())
val toolConfiguration = ToolPatternImpl(sourceSets.extension, "${project.layout.buildDirectory.get().asFile.path}/$name", *deps.toTypedArray())
toolConfiguration.configuration()
toolConfiguration.configure(this, false )
}