commit 43f1a305a2bcea6ff872b34438da778e5529f9c6 parent f97dda6e4dc3fabf30b4d9a0c9841c2f51ad006b Author: rhunk <101876869+rhunk@users.noreply.github.com> Date: Sun, 11 Aug 2024 16:05:07 +0200 fix(build): clean natives Diffstat:
M | native/build.gradle.kts | | | 26 | ++++++++++++++++---------- |
1 file changed, 16 insertions(+), 10 deletions(-)
diff --git a/native/build.gradle.kts b/native/build.gradle.kts @@ -44,17 +44,9 @@ fun getNativeFiles() = File(projectDir, "build/rustJniLibs/android").listFiles() abiFolder.takeIf { it.isDirectory }?.listFiles()?.toList() ?: emptyList() } -tasks.register("cleanNatives") { - doLast { - println("Cleaning native files") - getNativeFiles()?.forEach { file -> - file.deleteRecursively() - } - } -} -tasks.named("preBuild").configure { - dependsOn("cleanNatives", "cargoBuild") +val buildAndRename by tasks.registering { + dependsOn("cargoBuild") doLast { getNativeFiles()?.forEach { file -> if (file.name.endsWith(".so")) { @@ -64,3 +56,17 @@ tasks.named("preBuild").configure { } } } + +val cleanNatives by tasks.registering { + finalizedBy(buildAndRename) + doFirst { + println("Cleaning native files") + getNativeFiles()?.forEach { file -> + file.deleteRecursively() + } + } +} + +tasks.named("preBuild").configure { + dependsOn(cleanNatives) +}