* fix gradle developer config creation task with discussed suggestions * fix access token not set error message
24 lines
846 B
Groovy
24 lines
846 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 mapboxAccessToken = "$System.env.MAPBOX_ACCESS_TOKEN"
|
|
if (mapboxAccessToken == "null") {
|
|
System.out.println("You should set the MAPBOX_ACCESS_TOKEN environment variable.")
|
|
mapboxAccessToken = "YOUR_MAPBOX_ACCESS_TOKEN_GOES_HERE"
|
|
}
|
|
String tokenFileContents = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
|
|
"<resources>\n" +
|
|
" <string name=\"mapbox_access_token\">" + mapboxAccessToken + "</string>\n" +
|
|
"</resources>"
|
|
tokenFile.write(tokenFileContents)
|
|
}
|
|
}
|
|
|
|
gradle.projectsEvaluated {
|
|
preBuild.dependsOn('accessToken')
|
|
}
|