23 lines
737 B
Groovy
23 lines
737 B
Groovy
//
|
|
// Configuration file for gradle build execution.
|
|
//
|
|
|
|
task accessToken {
|
|
def tokenFile = new File("${projectDir}/src/main/res/values/developer-config.xml")
|
|
if (!tokenFile.exists()) {
|
|
String tokenFileContents = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
|
|
"<resources>\n" +
|
|
" <string name=\"mapbox_access_token\">" + "$System.env.MAPBOX_ACCESS_TOKEN" + "</string>\n" +
|
|
"</resources>"
|
|
|
|
if (tokenFileContents == null) {
|
|
throw new InvalidUserDataException("You must set the MAPBOX_ACCESS_TOKEN environment variable.")
|
|
}
|
|
tokenFile.write(tokenFileContents)
|
|
}
|
|
}
|
|
|
|
gradle.projectsEvaluated {
|
|
preBuild.dependsOn('accessToken')
|
|
}
|