summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcyBerta <cyberta@riseup.net>2017-09-21 12:37:37 +0200
committercyBerta <cyberta@riseup.net>2017-09-21 12:37:37 +0200
commitb9fcb0f81411cecebe4f9252910b634423ac6006 (patch)
tree0b93f5ec3e440e0508496eea4edef7e8872c01cd
parent6f5e56314d199723d1ff41c05ce46204727d53ab (diff)
update ics-openvpn: cleanup build.gradle
-rw-r--r--app/build.gradle39
1 files changed, 15 insertions, 24 deletions
diff --git a/app/build.gradle b/app/build.gradle
index af44b9a2..97ce9c35 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -141,34 +141,25 @@ task copyIcsOpenVPNImages( type: Copy ) {
} into '.'
}
-//TODO: avoid code duplication
// thanks to http://pleac.sourceforge.net/pleac_groovy/fileaccess.html
task removeDuplicatedStrings() {
println "removeDuplicatedStrings"
new File('.').eachFileRecurse {
- if(it.name.equals('strings.xml')) {
- def ics_openvpn_file = file(it.absolutePath.replace('strings.xml', 'strings-icsopenvpn.xml'))
- if(ics_openvpn_file.exists()) {
- def ics_openvpn_strings_names = (new XmlParser()).parse(ics_openvpn_file)
- def current_file = it
-
- ics_openvpn_strings_names.string.each {
- processFileInplace(current_file) { text ->
- text.replaceAll('.*name=\"' + it.attribute('name') + '\".*(\n)*.*string>.*\n+', '')
- }
- }
- }
- } else if (it.name.equals('plurals.xml')) {
- def ics_openvpn_file = file(it.absolutePath.replace('plurals.xml', 'plurals-icsopenvpn.xml'))
- if(ics_openvpn_file.exists()) {
- def ics_openvpn_strings_names = (new XmlParser()).parse(ics_openvpn_file)
- def current_file = it
-
- ics_openvpn_strings_names.string.each {
- processFileInplace(current_file) { text ->
- text.replaceAll('.*name=\"' + it.attribute('name') + '\".*(\n)*.*string>.*\n+', '')
- }
- }
+ if(it.name.equals('strings.xml') || it.name.equals('plurals.xml')) {
+ replaceDuplicatesForSource(it, it.name.substring(0, it.name.lastIndexOf('.')))
+ }
+ }
+}
+
+def replaceDuplicatesForSource(File it, String type) {
+ def ics_openvpn_file = file(it.absolutePath.replace(type+'.xml', type+'-icsopenvpn.xml'))
+ if(ics_openvpn_file.exists()) {
+ def ics_openvpn_strings_names = (new XmlParser()).parse(ics_openvpn_file)
+ def current_file = it
+
+ ics_openvpn_strings_names.string.each {
+ processFileInplace(current_file) { text ->
+ text.replaceAll('.*name=\"' + it.attribute('name') + '\".*(\n)*.*string>.*\n+', '')
}
}
}