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)!
This commit is contained in:
OMGeeky
2023-01-31 22:00:15 +01:00
parent 82b904d176
commit 1f365b170e
2 changed files with 19 additions and 8 deletions

View File

@@ -1,6 +1,3 @@
# Android ignores
app/src/main/res
app/src/main/assets
gen/
bin/
target/

View File

@@ -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
}