From 48c2c2f7850901ce4913e3eca74c5078613100c1 Mon Sep 17 00:00:00 2001 From: "Kenneth J. Shackleton" Date: Thu, 16 Nov 2023 09:55:13 +0000 Subject: [PATCH] Idiomatic use of layout.buildDirectory. Signed-off-by: Kenneth J. Shackleton --- OpenSSL/build.gradle.kts | 43 +++++++++++++++++---------------- Selektric/build.gradle.kts | 2 +- gradle.properties | 1 - selekt-android/build.gradle.kts | 8 +++--- selekt-java/build.gradle.kts | 6 ++--- selekt-sqlite3/build.gradle.kts | 2 +- 6 files changed, 31 insertions(+), 31 deletions(-) diff --git a/OpenSSL/build.gradle.kts b/OpenSSL/build.gradle.kts index 15f73a4316..019ff1d62b 100644 --- a/OpenSSL/build.gradle.kts +++ b/OpenSSL/build.gradle.kts @@ -27,17 +27,14 @@ plugins { id("de.undercouch.download") version Versions.GRADLE_DOWNLOAD_TASK_PLUGIN.version } -fun Project.openSslVersion() = arrayOf( - "${property("openssl.version")}", - "${property("openssl.version.suffix")}" -).joinToString("") +fun Project.openSslVersion() = property("openssl.version").toString() val openSslBaseUrl = "https://www.openssl.org/source" fun Project.openSslUrl() = "$openSslBaseUrl/openssl-${openSslVersion()}.tar.gz" fun Project.openSslPgpUrl() = "$openSslBaseUrl/openssl-${openSslVersion()}.tar.gz.asc" -val archive = File("${layout.buildDirectory.get()}/tmp/openssl-${openSslVersion()}.tar.gz") -val archivePgp = File("${archive.path}.asc") +val archive: Provider = layout.buildDirectory.file("tmp/openssl-${openSslVersion()}.tar.gz") +val archivePgp: Provider = layout.buildDirectory.file("tmp/openssl-${openSslVersion()}.tar.gz.asc") tasks.register("downloadOpenSslPgp") { val url = openSslPgpUrl() @@ -63,13 +60,13 @@ tasks.register("downloadOpenSsl") { } tasks.register("verifyOpenSslPgpChecksum") { - src(archivePgp) + src(archivePgp.get().asFile) algorithm("SHA-256") checksum("${project.property("openssl.pgp.sha256")}") } tasks.register("verifyOpenSslChecksum") { - src(archive) + src(archive.get().asFile) algorithm("SHA-256") checksum("${project.property("openssl.sha256")}") } @@ -78,19 +75,19 @@ tasks.register("verifyOpenSslSignature") { inputs.files(archivePgp, archive) commandLine( "gpg", "--no-default-keyring", "--keyring", "$projectDir/openssl.gpg", "--verify", - archivePgp, archive + archivePgp.get().asFile, archive.get().asFile ) } -fun openSslWorkingDir(target: String) = archive.run { - File("${layout.buildDirectory.get()}/generated/$target/${name.substringBefore(".tar.gz")}") -}.path +fun openSslWorkingDir(target: String): Provider = archive.run { + layout.buildDirectory.dir("generated/$target/${get().asFile.name.substringBefore(".tar.gz")}") +} arrayOf("armeabi-v7a", "arm64-v8a", "x86", "x86_64").forEach { val titleCaseName = it.replaceFirstChar { c -> c.uppercaseChar() } tasks.register("unpackOpenSsl$titleCaseName") { from(tarTree(archive)) - into("${layout.buildDirectory.get()}/generated/$it") + into(layout.buildDirectory.dir("generated/$it")) dependsOn("downloadOpenSsl") } @@ -100,13 +97,14 @@ arrayOf("armeabi-v7a", "arm64-v8a", "x86", "x86_64").forEach { inputs.property("version", openSslVersion()) outputs.files(fileTree("${openSslWorkingDir(it)}/include") { include("**/*.h") }) .withPropertyName("headers") - outputs.dir("${layout.buildDirectory.get()}/libs/$it").withPropertyName("lib") + outputs.dir(layout.buildDirectory.dir("libs/$it")).withPropertyName("lib") outputs.cacheIf { false } // TODO Restore me. workingDir(projectDir) commandLine("./build_libraries.sh") args( - archive.run { File("${layout.buildDirectory.get()}/generated" + - "/$it/${name.substringBefore(".tar.gz")}") }.path, + archive.run { layout.buildDirectory.file("generated" + + "/$it/${get().asFile.name.substringBefore(".tar.gz")}") + }.get().asFile.path, it, 21 ) @@ -130,12 +128,12 @@ fun osName() = System.getProperty("os.name").lowercase(Locale.US).run { fun targetIdentifier() = "${osName()}-${System.getProperty("os.arch")}" -val openSslWorkingDir: String = openSslWorkingDir(targetIdentifier()) +val openSslWorkingDir: Provider = openSslWorkingDir(targetIdentifier()) // FIXME Some of the host building logic parallels Android's above. Re-purpose? tasks.register("unpackOpenSslHost") { from(tarTree(archive)) - into("${layout.buildDirectory.get()}/generated/${targetIdentifier()}") + into(layout.buildDirectory.dir("generated/${targetIdentifier()}")) dependsOn("downloadOpenSsl") mustRunAfter("clean") } @@ -144,10 +142,11 @@ tasks.register("configureHost") { dependsOn("unpackOpenSslHost") inputs.property("target", targetIdentifier()) inputs.property("version", openSslVersion()) + workingDir(openSslWorkingDir) + val openSslWorkingDir = openSslWorkingDir.get().asFile outputs.files("$openSslWorkingDir/Makefile", "$openSslWorkingDir/configdata.pm") .withPropertyName("configure") outputs.cacheIf { false } // TODO Restore me. - workingDir(openSslWorkingDir) commandLine("./config") } @@ -155,13 +154,14 @@ tasks.register("makeHost") { dependsOn("configureHost") inputs.property("target", targetIdentifier()) inputs.property("version", openSslVersion()) + workingDir(openSslWorkingDir) + val openSslWorkingDir = openSslWorkingDir.get().asFile arrayOf(".a").forEach { outputs.files("$openSslWorkingDir/libcrypto$it") .withPropertyName("libcrypto$it") } outputs.files(fileTree("$openSslWorkingDir/include") { include("**/*.h") }) .withPropertyName("headers") - workingDir(openSslWorkingDir) outputs.cacheIf { false } // TODO Restore me. commandLine("make") args("build_libs") @@ -172,9 +172,10 @@ tasks.register("assembleHost") { dependsOn("makeHost") inputs.property("target", targetIdentifier()) inputs.property("version", openSslVersion()) - val outputDir = "${layout.buildDirectory.get()}/libs/${targetIdentifier()}" + val outputDir = layout.buildDirectory.dir("libs/${targetIdentifier()}") outputs.dir(outputDir).withPropertyName("libs") outputs.cacheIf { false } // TODO Restore me. + val openSslWorkingDir = openSslWorkingDir.get().asFile from(fileTree(openSslWorkingDir) { arrayOf(".a").forEach { e -> include("**/libcrypto$e") diff --git a/Selektric/build.gradle.kts b/Selektric/build.gradle.kts index 99755e10ee..60eb659196 100644 --- a/Selektric/build.gradle.kts +++ b/Selektric/build.gradle.kts @@ -66,7 +66,7 @@ tasks.register("copyLibraries") { from(fileTree(".cxx-host") { include("**/*.dll", "**/*.dylib", "**/*.so") }) - into("${layout.buildDirectory.get()}/intermediates/libs/${platformIdentifier()}") + into(layout.buildDirectory.dir("intermediates/libs/${platformIdentifier()}")) } tasks.register("deleteCxxHost") { diff --git a/gradle.properties b/gradle.properties index 67a13b624f..cbc855296e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,7 +2,6 @@ selekt.versionName=0.21.0 selekt.nextVersionName=0.22.0 openssl.version=3.1.2 -openssl.version.suffix= openssl.sha256=a0ce69b8b97ea6a35b96875235aa453b966ba3cba8af2de23657d8b6767d6539 openssl.pgp.sha256=0c14b85a86966752f1cdc2a3306497010d5fb9d405070b64cbb201d7ad1eb61a diff --git a/selekt-android/build.gradle.kts b/selekt-android/build.gradle.kts index e6d14b1054..d1fc4670ff 100644 --- a/selekt-android/build.gradle.kts +++ b/selekt-android/build.gradle.kts @@ -52,7 +52,7 @@ android { arrayOf("debug", "main", "release", "test").forEach { sourceSets[it].java.srcDir("src/$it/kotlin") } - sourceSets["test"].resources.srcDir("${layout.buildDirectory.get()}/intermediates/libs") + sourceSets["test"].resources.srcDir(layout.buildDirectory.dir("intermediates/libs")) publishing { singleVariant("release") { withJavadocJar() @@ -92,10 +92,10 @@ koverReport { tasks.register("copyJniLibs") { from( - fileTree("${project(":selekt-sqlite3").layout.buildDirectory.get()}/intermediates/libs"), - fileTree("${project(":Selektric").layout.buildDirectory.get()}/intermediates/libs") + fileTree(project(":selekt-sqlite3").layout.buildDirectory.dir("intermediates/libs")), + fileTree(project(":Selektric").layout.buildDirectory.dir("intermediates/libs")) ) - into("${layout.buildDirectory.get()}/intermediates/libs/jni") + into(layout.buildDirectory.dir("intermediates/libs/jni")) } tasks.register("buildNativeHost") { diff --git a/selekt-java/build.gradle.kts b/selekt-java/build.gradle.kts index 68558d6914..3cc7858acb 100644 --- a/selekt-java/build.gradle.kts +++ b/selekt-java/build.gradle.kts @@ -44,7 +44,7 @@ sourceSets { create("integrationTest") { compileClasspath += sourceSets.main.get().output runtimeClasspath += sourceSets.main.get().output - resources.srcDir("${layout.buildDirectory.get()}/intermediates/libs") + resources.srcDir(layout.buildDirectory.dir("intermediates/libs")) } } @@ -88,8 +88,8 @@ tasks.register("buildHostSQLite") { } tasks.register("copyJniLibs") { - from(fileTree("${project(":selekt-sqlite3").layout.buildDirectory.get()}/intermediates/libs")) - into("${layout.buildDirectory.get()}/intermediates/libs/jni") + from(fileTree(project(":selekt-sqlite3").layout.buildDirectory.dir("intermediates/libs"))) + into(layout.buildDirectory.dir("intermediates/libs/jni")) } tasks.withType().configureEach { diff --git a/selekt-sqlite3/build.gradle.kts b/selekt-sqlite3/build.gradle.kts index 58b5fbf006..695a2c371c 100644 --- a/selekt-sqlite3/build.gradle.kts +++ b/selekt-sqlite3/build.gradle.kts @@ -152,7 +152,7 @@ fun platformIdentifier() = "${osName()}-${System.getProperty("os.arch")}" tasks.register("buildHost") { dependsOn("makeSQLite") from(".cxx-host/sqlite3") - into("${layout.buildDirectory.get()}/intermediates/libs/${platformIdentifier()}") + into(layout.buildDirectory.dir("intermediates/libs/${platformIdentifier()}")) include("*.dll", "*.dylib", "*.so") }