From 1f365b170e44d7db9aac2b2c8e0cf3ce7f914d76 Mon Sep 17 00:00:00 2001 From: OMGeeky Date: Tue, 31 Jan 2023 22:00:15 +0100 Subject: [PATCH] improves the gradle tasks for copying the maps and translations Instead of copying the files to the normal res folder they get copied to the build folder, which gives the user the hint that they are generated and should not be edited in this location. > **Warning** After pulling this commit both folders '/app/src/main/res' and 'app/src/main/assets' should be deleted if they exist, since they are no longer ignored (since they don't get used anymore)! --- AndorsTrail/.gitignore | 3 --- AndorsTrail/app/build.gradle | 24 +++++++++++++++++++----- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/AndorsTrail/.gitignore b/AndorsTrail/.gitignore index 0c4cccb28..6d57601c3 100644 --- a/AndorsTrail/.gitignore +++ b/AndorsTrail/.gitignore @@ -1,6 +1,3 @@ -# Android ignores -app/src/main/res -app/src/main/assets gen/ bin/ target/ diff --git a/AndorsTrail/app/build.gradle b/AndorsTrail/app/build.gradle index f37768ed6..882613550 100644 --- a/AndorsTrail/app/build.gradle +++ b/AndorsTrail/app/build.gradle @@ -21,6 +21,12 @@ android { applicationIdSuffix 'beta2' } } + sourceSets { + main { + res.srcDirs = ['build/gen-res', 'src/main/res'] + assets.srcDirs = ['build/gen-assets', 'src/main/assets'] + } + } } dependencies { @@ -30,23 +36,31 @@ dependencies { task copyRes(type: Copy) { description "Copies the res folder to the modules res folder (& renames .tmx to .xml)" from "${rootDir}/res" - into "${projectDir}/src/main/res" + into "${projectDir}/build/gen-res" rename "(.*)\\.tmx", "\$1.xml" } task copyTranslation(type: Copy) { description("Copies the translation files to the modules translations folder") from "${rootDir}/assets/translation" - into "${projectDir}/src/main/assets/translation" + into "${projectDir}/build/gen-assets/translation" } task cleanup(type: Delete) { description("Deletes the assets/translation and the res folder from the modules folder") - delete "${projectDir}/src/main/res", "${projectDir}/src/main/assets/translation" + delete "${projectDir}/build/gen-res", "${projectDir}/build/gen-assets/translation" } afterEvaluate { - preBuild.dependsOn project.tasks.copyRes - preBuild.dependsOn project.tasks.copyTranslation + mergeDebugResources.dependsOn project.tasks.copyRes + extractDeepLinksDebug.dependsOn project.tasks.copyRes + mergeReleaseResources.dependsOn project.tasks.copyRes + extractDeepLinksRelease.dependsOn project.tasks.copyRes + + mergeDebugAssets.dependsOn project.tasks.copyTranslation + mergeReleaseAssets.dependsOn project.tasks.copyTranslation + extractDeepLinksDebug.dependsOn project.tasks.copyTranslation + extractDeepLinksRelease.dependsOn project.tasks.copyTranslation + clean.dependsOn project.tasks.cleanup }