Created
December 19, 2018 15:06
-
-
Save omegasoft7/2e8b53bf177ecc52de14be0a6cfbe3f8 to your computer and use it in GitHub Desktop.
Change String Resources from Gradle
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
applicationVariants.all { variant -> | |
variant.mergeResources.doLast { | |
def dir = new File("${buildDir}/intermediates/res/merged/${variant.dirName}") //iterating through resources, prepared for including to APK (merged resources) | |
println("Resources dir " + dir) | |
dir.eachFileRecurse { file -> | |
if(file.name.endsWith(".xml")) { //processing only files, which names and with .xml | |
String content = file.getText('UTF-8') | |
if(content != null && content.contains("Bill")) { | |
println("Replacing name in " + file) | |
content = content.replace("Bill", "Will") //replacing all Bill words with Will word in files | |
file.write(content, 'UTF-8') | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment