forked from mapbox/mapbox-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeveloper-config.gradle
More file actions
23 lines (19 loc) · 898 Bytes
/
Copy pathdeveloper-config.gradle
File metadata and controls
23 lines (19 loc) · 898 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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") {
logger.error("warning: MAPBOX_ACCESS_TOKEN environment variable is not set.")
logger.error("Note: It is recommended to edit the value in res/values/developer-config.xml file.")
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')
}