24 lines
752 B
Groovy
24 lines
752 B
Groovy
//
|
|
// Configuration file for gradle build execution.
|
|
//
|
|
|
|
task apiKey {
|
|
def tokenFile = new File("${projectDir}/src/main/res/values/developer-config.xml")
|
|
if (!tokenFile.exists()) {
|
|
String apiKey = "$System.env.MLN_API_KEY"
|
|
if (apiKey == "null") {
|
|
System.out.println("You should set the MLN_API_KEY environment variable.")
|
|
apiKey = "YOUR_API_KEY_GOES_HERE"
|
|
}
|
|
String tokenFileContents = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
|
|
"<resources>\n" +
|
|
" <string name=\"api_key\">" + apiKey + "</string>\n" +
|
|
"</resources>"
|
|
tokenFile.write(tokenFileContents)
|
|
}
|
|
}
|
|
|
|
gradle.projectsEvaluated {
|
|
preBuild.dependsOn('apiKey')
|
|
}
|