buildDir deprecated, use layout.buildDirectory instead (#2697)

gradle/gradle#20210
gradle/gradle#24820
This commit is contained in:
Howard Wu 2023-08-19 12:27:55 +08:00 committed by GitHub
parent 894f9f481c
commit 0229e294d0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 14 deletions

View File

@ -49,7 +49,9 @@ cmaker {
} }
buildTypes { buildTypes {
if (it.name == "release") { if (it.name == "release") {
arguments += "-DDEBUG_SYMBOLS_PATH=${buildDir.absolutePath}/symbols" arguments += "-DDEBUG_SYMBOLS_PATH=${
layout.buildDirectory.dir("symbols").get().asFile.absolutePath
}"
} }
} }
} }
@ -73,7 +75,7 @@ val androidSourceCompatibility by extra(JavaVersion.VERSION_17)
val androidTargetCompatibility by extra(JavaVersion.VERSION_17) val androidTargetCompatibility by extra(JavaVersion.VERSION_17)
tasks.register("Delete", Delete::class) { tasks.register("Delete", Delete::class) {
delete(rootProject.buildDir) delete(rootProject.layout.buildDirectory)
} }
subprojects { subprojects {

View File

@ -81,10 +81,13 @@ android.applicationVariants.all {
val variantCapped = name.replaceFirstChar { it.uppercase() } val variantCapped = name.replaceFirstChar { it.uppercase() }
val variantLowered = name.lowercase() val variantLowered = name.lowercase()
val outSrcDir = file("$buildDir/generated/source/signInfo/${variantLowered}") val outSrcDir =
layout.buildDirectory.dir("generated/source/signInfo/${variantLowered}").get()
val signInfoTask = tasks.register("generate${variantCapped}SignInfo") { val signInfoTask = tasks.register("generate${variantCapped}SignInfo") {
dependsOn(":app:validateSigning${variantCapped}") dependsOn(":app:validateSigning${variantCapped}")
val sign = rootProject.project(":app").extensions.getByType(ApplicationExtension::class.java).buildTypes.named(variantLowered).get().signingConfig val sign = rootProject.project(":app").extensions
.getByType(ApplicationExtension::class.java)
.buildTypes.named(variantLowered).get().signingConfig
val outSrc = file("$outSrcDir/org/lsposed/lspd/util/SignInfo.java") val outSrc = file("$outSrcDir/org/lsposed/lspd/util/SignInfo.java")
outputs.file(outSrc) outputs.file(outSrc)
doLast { doLast {
@ -107,7 +110,7 @@ android.applicationVariants.all {
) )
} }
} }
registerJavaGeneratingTask(signInfoTask, outSrcDir) registerJavaGeneratingTask(signInfoTask, outSrcDir.asFile)
} }
dependencies { dependencies {

View File

@ -134,7 +134,7 @@ fun afterEval() = android.applicationVariants.forEach { variant ->
val flavorCapped = variant.flavorName!!.replaceFirstChar { it.uppercase() } val flavorCapped = variant.flavorName!!.replaceFirstChar { it.uppercase() }
val flavorLowered = variant.flavorName!!.lowercase() val flavorLowered = variant.flavorName!!.lowercase()
val magiskDir = "$buildDir/magisk/$variantLowered" val magiskDir = layout.buildDirectory.dir("magisk/$variantLowered")
val moduleId = "${flavorLowered}_$moduleBaseId" val moduleId = "${flavorLowered}_$moduleBaseId"
val zipFileName = "$moduleName-v$verName-$verCode-${flavorLowered}-$buildTypeLowered.zip" val zipFileName = "$moduleName-v$verName-$verCode-${flavorLowered}-$buildTypeLowered.zip"
@ -200,24 +200,25 @@ fun afterEval() = android.applicationVariants.forEach { variant ->
rename(".*\\.apk", "daemon.apk") rename(".*\\.apk", "daemon.apk")
} }
into("lib") { into("lib") {
from("${buildDir}/intermediates/stripped_native_libs/$variantCapped/out/lib") { from(layout.buildDirectory.dir("intermediates/stripped_native_libs/$variantCapped/out/lib")) {
include("**/liblspd.so") include("**/liblspd.so")
} }
} }
into("bin") { into("bin") {
from("${project(":dex2oat").buildDir}/intermediates/cmake/$buildTypeLowered/obj") { from(project(":dex2oat").layout.buildDirectory.dir("intermediates/cmake/$buildTypeLowered/obj")) {
include("**/dex2oat") include("**/dex2oat")
} }
} }
val dexOutPath = if (buildTypeLowered == "release") val dexOutPath = if (buildTypeLowered == "release")
"$buildDir/intermediates/dex/$variantCapped/minify${variantCapped}WithR8" else layout.buildDirectory.dir("intermediates/dex/$variantCapped/minify${variantCapped}WithR8")
"$buildDir/intermediates/dex/$variantCapped/mergeDex$variantCapped" else
layout.buildDirectory.dir("intermediates/dex/$variantCapped/mergeDex$variantCapped")
into("framework") { into("framework") {
from(dexOutPath) from(dexOutPath)
rename("classes.dex", "lspd.dex") rename("classes.dex", "lspd.dex")
} }
val injected = objects.newInstance<Injected>(magiskDir) val injected = objects.newInstance<Injected>(magiskDir.get().asFile.path)
doLast { doLast {
injected.factory.fileTree().from(injected.magiskDir).visit { injected.factory.fileTree().from(injected.magiskDir).visit {
if (isDirectory) return@visit if (isDirectory) return@visit
@ -275,7 +276,7 @@ val killLspd = task<Exec>("killLspd") {
val pushDaemon = task<Exec>("pushDaemon") { val pushDaemon = task<Exec>("pushDaemon") {
group = "LSPosed" group = "LSPosed"
dependsOn(":daemon:assembleDebug") dependsOn(":daemon:assembleDebug")
workingDir("${project(":daemon").buildDir}/outputs/apk/debug") workingDir(project(":daemon").layout.buildDirectory.dir("outputs/apk/debug"))
commandLine(adb, "push", "daemon-debug.apk", "/data/local/tmp/daemon.apk") commandLine(adb, "push", "daemon-debug.apk", "/data/local/tmp/daemon.apk")
} }
val pushDaemonNative = task<Exec>("pushDaemonNative") { val pushDaemonNative = task<Exec>("pushDaemonNative") {
@ -289,7 +290,7 @@ val pushDaemonNative = task<Exec>("pushDaemonNative") {
} }
outputStream.toString().trim() outputStream.toString().trim()
} }
workingDir("${project(":daemon").buildDir}/intermediates/stripped_native_libs/debug/out/lib/$abi") workingDir(project(":daemon").layout.buildDirectory.dir("intermediates/stripped_native_libs/debug/out/lib/$abi"))
} }
commandLine(adb, "push", "libdaemon.so", "/data/local/tmp/libdaemon.so") commandLine(adb, "push", "libdaemon.so", "/data/local/tmp/libdaemon.so")
} }
@ -307,7 +308,7 @@ val tmpApk = "/data/local/tmp/lsp.apk"
val pushApk = task<Exec>("pushApk") { val pushApk = task<Exec>("pushApk") {
group = "LSPosed" group = "LSPosed"
dependsOn(":app:assembleDebug") dependsOn(":app:assembleDebug")
workingDir("${project(":app").buildDir}/outputs/apk/debug") workingDir(project(":app").layout.buildDirectory.dir("outputs/apk/debug"))
commandLine(adb, "push", "app-debug.apk", tmpApk) commandLine(adb, "push", "app-debug.apk", tmpApk)
} }
val openApp = task<Exec>("openApp") { val openApp = task<Exec>("openApp") {