Setting a value in an xml in Gradle (similar to Ants xmltask)

Hello. I am trying to migrate my Android projects from an Eclipse & Ant configuration to Android Studio and Gradle. Thehave special builds for different app stores with different tracking ids, ad ids and so on. On Eclipse I had a ant xmltask that set the values of this ids in their respective xml files. For example I had:

<xmltask source="res/values/admob.xml" dest="res/values/admob.xml">
    <replace path="//string[@name='bottom_ad_unit_id']/text()" withText="${bottomAdUnitId}"/>
    </xmltask>

For each store I only had to set bottomAdUnitId with the correct id and call run the task.

Is there something similar in Gradle that would allow me to do the same thing?

Look into the XmlSlurper in Groovy.




def slurper = new XmlSlurper(false, false)



slurper.keepWhitespace = true



def xmlTree = slurper.parseText(xmlcontent)

 def info = xmlTree .info[0]



info.@status = 'release'  

will change

ivy-module info status=“snapshot” /ivy-module

to

ivy-module info status=“release” /ivy-module>

update: couldnt get nice xml to work…but you get the idea

/Andreas

This question was answered on stackoverflow. Please avoid duplication in the future.