summaryrefslogtreecommitdiff
path: root/platform/android/gradle/gradle-config.gradle
blob: 83468066335ad36b171c63673ed13bc1a4d16742 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
//
// 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')
}