Created
November 28, 2015 11:43
-
-
Save saikrishna321/30b502cf4b556e90a1b2 to your computer and use it in GitHub Desktop.
This file contains 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
task debugAppiumTest { | |
def protocol = "https://" | |
def localIp = obtainCurrentIpAddress() | |
def port = "8443" | |
def backendAddress = protocol + localIp + ":" + port + "/" | |
File valuesFile = file("/Users/saikrisv/git/iot/KanJuice/app/src/main/res/values/strings.xml") | |
if (valuesFile.exists()) { | |
String content = valuesFile.getText('UTF-8') | |
String replaceContent = "<string name=\"connection\"></string>" | |
StringBuilder sys_ip = new StringBuilder(replaceContent); | |
println(sys_ip.replace(26, 26, "#const_backend_url#")); | |
content = content.replaceAll("[https,0-9,]", backendAddress); | |
valuesFile.write(content, 'UTF-8') | |
println("Replacing #const_backend_url# with " + backendAddress + " in file: " + valuesFile.name) | |
} else { | |
println("File: " + valuesFile.path + " does not exist") | |
} | |
} | |
def obtainCurrentIpAddress() { | |
InetAddress inetAddress = InetAddress.getLocalHost(); | |
byte[] address = inetAddress.getAddress(); | |
String ipAddress = ""; | |
for (int i = 0; i < address.length; i++) { | |
if (i > 0) { | |
ipAddress += "."; | |
} | |
ipAddress += address[i] & 0xFF; | |
} | |
ipAddress | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment