Gradle now copy most of assets
authorLoic Blot <loic.blot@unix-experience.fr>
Wed, 5 Dec 2018 19:08:46 +0000 (20:08 +0100)
committerLoic Blot <loic.blot@unix-experience.fr>
Wed, 5 Dec 2018 19:08:46 +0000 (20:08 +0100)
It depends on cleanAssets, ensuring they are always fresh

build/android/Makefile
build/android/build.gradle

index c4110aadd39d3b35055fc1c909415145725fdb42..b6a27450caf57c84a8eccbed8fd48e716820d404 100644 (file)
@@ -13,10 +13,6 @@ ANDR_ROOT = $(shell pwd)
 PROJ_ROOT = $(shell realpath $(ANDR_ROOT)/../..)
 APP_ROOT = $(ANDR_ROOT)/src/main
 
-GAMES_TO_COPY = minetest_game
-MODS_TO_COPY =
-
-
 VERSION_MAJOR := $(shell cat $(PROJ_ROOT)/CMakeLists.txt | \
        grep ^set\(VERSION_MAJOR\ | sed 's/)/ /' | cut -f2 -d' ')
 VERSION_MINOR := $(shell cat $(PROJ_ROOT)/CMakeLists.txt | \
@@ -732,26 +728,7 @@ assets : $(ASSETS_TIMESTAMP)
        if [ $$REFRESH -ne 0 ] ; then                                              \
        echo "assets changed, refreshing...";                                      \
        $(MAKE) clean_assets;                                                      \
-       mkdir -p ${APP_ROOT}/assets/Minetest;                                      \
-       cp ${PROJ_ROOT}/minetest.conf.example ${APP_ROOT}/assets/Minetest;         \
-       cp ${PROJ_ROOT}/README.md ${APP_ROOT}/assets/Minetest;                     \
-       cp -r ${PROJ_ROOT}/builtin ${APP_ROOT}/assets/Minetest;                    \
-       mkdir -p ${APP_ROOT}/assets/Minetest/client;                                  \
-       cp -r ${PROJ_ROOT}/client/shaders ${APP_ROOT}/assets/Minetest/client;      \
-       cp ${PROJ_ROOT}/doc/lgpl-2.1.txt ${APP_ROOT}/assets/Minetest/LICENSE.txt;  \
-       mkdir -p ${APP_ROOT}/assets/Minetest/fonts;                                   \
-       cp -r ${PROJ_ROOT}/fonts/*.ttf ${APP_ROOT}/assets/Minetest/fonts/;         \
-       mkdir -p ${APP_ROOT}/assets/Minetest/games;                                   \
-       for game in ${GAMES_TO_COPY}; do                                           \
-           cp -r ${PROJ_ROOT}/games/$$game ${APP_ROOT}/assets/Minetest/games/;    \
-       done;                                                                      \
-       mkdir -p ${APP_ROOT}/assets/Minetest/mods;                                    \
-       for mod in ${MODS_TO_COPY}; do                                             \
-           cp -r ${PROJ_ROOT}/mods/$$mod ${APP_ROOT}/assets/Minetest/mods/;       \
-       done;                                                                      \
-       cp -r ${PROJ_ROOT}/po ${APP_ROOT}/assets/Minetest;                         \
-       cp -r ${PROJ_ROOT}/textures ${APP_ROOT}/assets/Minetest;                   \
-       mkdir -p ${APP_ROOT}/assets/Minetest/media;                                \
+       ./gradlew copyAssets;                                                      \
        cp -r ${IRRLICHT_DIR}/media/Shaders ${APP_ROOT}/assets/Minetest/media;     \
        cd ${APP_ROOT}/assets ||  exit 1;                                          \
        find . -name "timestamp" -exec rm {} \; ;                                  \
index 029dee4b1d05a5065d7acae6581ab41aca7591ae..588ac3f149e1c5f6072f7a123f57d97ac014d63d 100644 (file)
@@ -72,6 +72,48 @@ task cleanAssets(type: Delete) {
        delete 'src/main/assets'
 }
 
+task copyAssets {
+       dependsOn 'cleanAssets'
+       mkdir "src/main/assets"
+
+       def mtAssetsFolder = "src/main/assets/Minetest"
+       def projRoot = "../.."
+       def gameToCopy = "minetest_game"
+
+       doLast {
+               mkdir "${mtAssetsFolder}"
+               mkdir "${mtAssetsFolder}/client"
+               mkdir "${mtAssetsFolder}/fonts"
+               mkdir "${mtAssetsFolder}/games"
+               mkdir "${mtAssetsFolder}/media"
+
+               copy {
+                       from "${projRoot}/minetest.conf.example", "${projRoot}/README.md" into mtAssetsFolder
+               }
+               copy {
+                       from "${projRoot}/doc/lgpl-2.1.txt" into "${mtAssetsFolder}/LICENSE.txt"
+               }
+               copy {
+                       from "${projRoot}/builtin" into "${mtAssetsFolder}/builtin"
+               }
+               copy {
+                       from "${projRoot}/client/shaders" into "${mtAssetsFolder}/client/shaders"
+               }
+               copy {
+                       from "${projRoot}/fonts" include "*.ttf" into "${mtAssetsFolder}/fonts"
+               }
+               copy {
+                       from "${projRoot}/games/${gameToCopy}" into "${mtAssetsFolder}/games/${gameToCopy}"
+               }
+               copy {
+                       from "${projRoot}/po" into "${mtAssetsFolder}/po"
+               }
+               copy {
+                       from "${projRoot}/textures" into "${mtAssetsFolder}/textures"
+               }
+       }
+}
+
 task cleanIconv(type: Delete) {
        delete 'deps/libiconv'
 }
@@ -118,8 +160,8 @@ task cleanGMP(type: Delete) {
 }
 
 task cleanAll(type: Delete, dependsOn: [clean, cleanAssets, cleanIconv,
-                                                                               cleanFreetype, cleanIrrlicht, cleanLevelDB, cleanSQLite3, cleanCURL,
-                                                                               cleanOpenSSL, cleanOpenAL, cleanOgg, cleanGMP]) {
+               cleanFreetype, cleanIrrlicht, cleanLevelDB, cleanSQLite3, cleanCURL,
+               cleanOpenSSL, cleanOpenAL, cleanOgg, cleanGMP]) {
        delete 'deps'
        delete 'gen'
        delete 'libs'