// // 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 = "\n" + "\n" + " " + mapboxAccessToken + "\n" + "" tokenFile.write(tokenFileContents) } } gradle.projectsEvaluated { preBuild.dependsOn('accessToken') }