From fee2e3ee27a36c9a33e3cd75c676a0edc33ccac5 Mon Sep 17 00:00:00 2001 From: sfan5 Date: Thu, 23 Feb 2023 11:32:42 +0100 Subject: [PATCH] Fix task ordering and more in Gradle Android build --- android/app/build.gradle | 74 ++++++++++++++++++++----------------- android/build.gradle | 1 - android/native/build.gradle | 21 +++++++---- 3 files changed, 54 insertions(+), 42 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index 0c7884e72..b268dd3cb 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -53,51 +53,59 @@ android { task prepareAssets() { def assetsFolder = "build/assets" - def projRoot = "../.." + def projRoot = rootDir.parent def gameToCopy = "minetest_game" - copy { - from "${projRoot}/minetest.conf.example", "${projRoot}/README.md" into assetsFolder + doFirst { + logger.lifecycle('Preparing assets at {}', assetsFolder) } - copy { - from "${projRoot}/doc/lgpl-2.1.txt" into "${assetsFolder}" - } - copy { - from "${projRoot}/builtin" into "${assetsFolder}/builtin" - } - copy { - from "${projRoot}/client/shaders" into "${assetsFolder}/client/shaders" - } - copy { - from "../native/deps/armeabi-v7a/Irrlicht/Shaders" into "${assetsFolder}/client/shaders/Irrlicht" - } - copy { - from "${projRoot}/fonts" include "*.ttf" into "${assetsFolder}/fonts" - } - copy { - from "${projRoot}/games/${gameToCopy}" into "${assetsFolder}/games/${gameToCopy}" - } - fileTree("${projRoot}/po").include("**/*.po").forEach { poFile -> - def moPath = "${assetsFolder}/locale/${poFile.parentFile.name}/LC_MESSAGES/" - file(moPath).mkdirs() - exec { - commandLine 'msgfmt', '-o', "${moPath}/minetest.mo", poFile + doLast { + copy { + from "${projRoot}/minetest.conf.example", "${projRoot}/README.md" into assetsFolder + } + copy { + from "${projRoot}/doc/lgpl-2.1.txt" into assetsFolder + } + copy { + from "${projRoot}/builtin" into "${assetsFolder}/builtin" + } + copy { + from "${projRoot}/client/shaders" into "${assetsFolder}/client/shaders" + } + copy { + from "../native/deps/armeabi-v7a/Irrlicht/Shaders" into "${assetsFolder}/client/shaders/Irrlicht" + } + copy { + from "${projRoot}/fonts" include "*.ttf" into "${assetsFolder}/fonts" + } + copy { + from "${projRoot}/games/${gameToCopy}" into "${assetsFolder}/games/${gameToCopy}" + } + copy { + from "${projRoot}/textures" into "${assetsFolder}/textures" } - } - copy { - from "${projRoot}/textures" into "${assetsFolder}/textures" - } - file("${assetsFolder}/.nomedia").text = "" + // compile translations + fileTree("${projRoot}/po").include("**/*.po").forEach { poFile -> + def moPath = "${assetsFolder}/locale/${poFile.parentFile.name}/LC_MESSAGES/" + file(moPath).mkdirs() + exec { + commandLine 'msgfmt', '-o', "${moPath}/minetest.mo", poFile + } + } + + file("${assetsFolder}/.nomedia").text = "" + } - task zipAssets(type: Zip) { + task zipAssets(dependsOn: prepareAssets, type: Zip) { archiveFileName = "Minetest.zip" - from "${assetsFolder}" + from assetsFolder destinationDirectory = file("src/main/assets") } } preBuild.dependsOn zipAssets +prepareAssets.dependsOn ':native:getDeps' // Map for the version code that gives each ABI a value. import com.android.build.OutputFile diff --git a/android/build.gradle b/android/build.gradle index cbe01c56f..ca27dcb53 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -33,5 +33,4 @@ allprojects { task clean(type: Delete) { delete rootProject.buildDir - delete 'native/deps' } diff --git a/android/native/build.gradle b/android/native/build.gradle index 6caec1379..452005164 100644 --- a/android/native/build.gradle +++ b/android/native/build.gradle @@ -52,18 +52,23 @@ android { // get precompiled deps task downloadDeps(type: Download) { + def depsDir = new File(buildDir.parent, 'deps') + def depsZip = new File(buildDir, 'deps.zip') + src 'https://github.com/minetest/minetest_android_deps/releases/download/latest/deps.zip' - dest new File(buildDir, 'deps.zip') + dest depsZip overwrite false -} -task getDeps(dependsOn: downloadDeps, type: Copy) { - def deps = new File(buildDir.parent, 'deps') - if (!deps.exists()) { - deps.mkdir() - from zipTree(downloadDeps.dest) - into deps + task getDeps(dependsOn: downloadDeps, type: Copy) { + depsDir.mkdir() + from zipTree(depsZip) + into depsDir + doFirst { logger.lifecycle('Extracting to {}', depsDir) } } } preBuild.dependsOn getDeps + +clean { + delete new File(buildDir.parent, 'deps') +} -- 2.44.0