Skip to content

Instantly share code, notes, and snippets.

@bitristan
Created January 11, 2016 05:48
Show Gist options
  • Save bitristan/4a56963f740f0c2234a7 to your computer and use it in GitHub Desktop.
Save bitristan/4a56963f740f0c2234a7 to your computer and use it in GitHub Desktop.
Replace str in file with groovy.
import groovy.io.FileType
def source = "import android.support.wearable"
def dest = "import ticwear.support.wearable"
def dir = new File("res")
dir.eachFileRecurse (FileType.FILES) { f ->
def fileText = f.text
fileText = (fileText =~ /${source}/).replaceAll(dest)
f.write(fileText)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment