From 65e6990582d264ad8fb4972836c69fb6a60b3010 Mon Sep 17 00:00:00 2001 From: Leith Bade Date: Tue, 13 Jan 2015 21:14:44 +1100 Subject: [PATCH] Grab access token from environment --- README.md | 2 +- android/java/app/build.gradle | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d1905037b..ca6c76380 100644 --- a/README.md +++ b/README.md @@ -165,7 +165,7 @@ For iOS and OS X use of the demo apps in Xcode, setup the access token by editin For Linux, set the environment variable `MAPBOX_ACCESS_TOKEN` to your token. -For Android, create the file `android/java/app/src/main/res/raw/token.txt` and insert the token as a single line. +For Android, gradle will take the value of `MAPBOX_ACCESS_TOKEN` and save it to `android/java/app/src/main/res/raw/token.txt` where the app will read it from. # Style diff --git a/android/java/app/build.gradle b/android/java/app/build.gradle index 96b8f0d1e..1bc65f6fa 100644 --- a/android/java/app/build.gradle +++ b/android/java/app/build.gradle @@ -1,5 +1,14 @@ apply plugin: 'com.android.application' +task accessToken { + def tokenFile = new File("app/src/main/res/raw/token.txt") + tokenFile.write(System.getenv('MAPBOX_ACCESS_TOKEN')) +} + +gradle.projectsEvaluated { + preBuild.dependsOn('accessToken') +} + android { compileSdkVersion 21 buildToolsVersion "21.1.2"