Skip to content

Commit fc055ef

Browse files
committed
Merge pull request #520 from mapzen/509-configurable-service-urls
Adds ability to inject search and routing base url at build time
2 parents e3bc4f2 + c1bd307 commit fc055ef

5 files changed

Lines changed: 19 additions & 6 deletions

File tree

app/build.gradle

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ apply plugin: 'kotlin-android'
1313
apply plugin: 'com.neenbedankt.android-apt'
1414
apply plugin: 'checkstyle'
1515

16+
def SEARCH_BASE_URL = hasProperty('searchBaseUrl') ? '"' + searchBaseUrl + '"' : "null";
17+
def ROUTE_BASE_URL = hasProperty('routeBaseUrl') ? '"' + routeBaseUrl + '"' : "null";
18+
1619
def VECTOR_TILE_API_KEY = hasProperty('vectorTileApiKey') ? '"' + vectorTileApiKey + '"' : "null";
1720
def PELIAS_API_KEY = hasProperty('peliasApiKey') ? '"' + peliasApiKey + '"' : "null";
1821
def VALHALLA_API_KEY = hasProperty('valhallaApiKey') ? '"' + valhallaApiKey + '"' : "null";
@@ -34,6 +37,8 @@ android {
3437
targetSdkVersion 22
3538
versionCode buildVersionCode()
3639
versionName version
40+
buildConfigField "String", "SEARCH_BASE_URL", SEARCH_BASE_URL
41+
buildConfigField "String", "ROUTE_BASE_URL", ROUTE_BASE_URL
3742
buildConfigField "String", "VECTOR_TILE_API_KEY", VECTOR_TILE_API_KEY
3843
buildConfigField "String", "PELIAS_API_KEY", PELIAS_API_KEY
3944
buildConfigField "String", "VALHALLA_API_KEY", VALHALLA_API_KEY

app/src/main/java/com/mapzen/erasermap/AndroidModule.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,11 @@ public AndroidModule(EraserMapApplication application) {
7979
}
8080

8181
@Provides @Singleton Pelias providePelias() {
82+
final String endpoint = BuildConfig.SEARCH_BASE_URL != null ?
83+
BuildConfig.SEARCH_BASE_URL : Pelias.DEFAULT_SERVICE_ENDPOINT;
8284
final RestAdapter.LogLevel logLevel = BuildConfig.DEBUG ?
8385
RestAdapter.LogLevel.FULL : RestAdapter.LogLevel.NONE;
84-
return Pelias.getPelias(logLevel);
86+
return Pelias.getPeliasWithEndpoint(endpoint, logLevel);
8587
}
8688

8789
@Provides @Singleton Speakerbox provideSpeakerbox() {

app/src/main/kotlin/com/mapzen/erasermap/model/ValhallaRouteManager.kt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
package com.mapzen.erasermap.model
22

33
import android.location.Location
4-
import com.mapzen.pelias.BuildConfig
4+
import com.mapzen.erasermap.BuildConfig
55
import com.mapzen.pelias.SimpleFeature
66
import com.mapzen.pelias.gson.Feature
77
import com.mapzen.valhalla.Route
88
import com.mapzen.valhalla.RouteCallback
99
import com.mapzen.valhalla.Router
10+
import com.mapzen.valhalla.ValhallaRouter
1011
import retrofit.RestAdapter
1112

1213
public class ValhallaRouteManager(val settings: AppSettings,
@@ -79,9 +80,14 @@ public class ValhallaRouteManager(val settings: AppSettings,
7980
}
8081

8182
private fun getInitializedRouter(type: Router.Type): Router {
83+
val endpoint = BuildConfig.ROUTE_BASE_URL ?: ValhallaRouter.DEFAULT_URL
8284
val logLevel = if (BuildConfig.DEBUG) RestAdapter.LogLevel.FULL else
8385
RestAdapter.LogLevel.NONE
84-
val router = routerFactory.getRouter().setApiKey(apiKey).setLogLevel(logLevel)
86+
val router = routerFactory.getRouter()
87+
.setApiKey(apiKey)
88+
.setEndpoint(endpoint)
89+
.setLogLevel(logLevel)
90+
.setDntEnabled(true)
8591
when(type) {
8692
Router.Type.DRIVING -> return router.setDriving()
8793
Router.Type.WALKING -> return router.setWalking()

scripts/deploy-master.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
#
33
# Builds master branch and uploads APK to s3://android.mapzen.com/erasermap-snapshots/.
44

5-
./gradlew assembleDevDebug -PmintApiKey=$MINT_API_KEY -PvectorTileApiKey=$VECTOR_TILE_API_KEY -PpeliasApiKey=$PELIAS_API_KEY -PvalhallaApiKey=$VALHALLA_API_KEY -PbuildNumber=$CIRCLE_BRANCH-$CIRCLE_BUILD_NUM
5+
./gradlew assembleDevDebug -PmintApiKey=$MINT_API_KEY -PvectorTileApiKey=$VECTOR_TILE_API_KEY -PpeliasApiKey=$PELIAS_API_KEY -PvalhallaApiKey=$VALHALLA_API_KEY -PbuildNumber=$CIRCLE_BRANCH-$CIRCLE_BUILD_NUM -PsearchBaseUrl="$SEARCH_BASE_URL" -ProuteBaseUrl="$ROUTE_BASE_URL"
66
s3cmd put app/build/outputs/apk/app-dev-debug.apk s3://android.mapzen.com/erasermap-latest.apk
77
s3cmd put app/build/outputs/apk/app-dev-debug.apk s3://android.mapzen.com/erasermap-snapshots/master-$CIRCLE_BUILD_NUM.apk

scripts/deploy.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44

55
if [ -z ${PERFORM_RELEASE} ]
66
then
7-
./gradlew assembleDevDebug -PmintApiKey=$MINT_API_KEY -PvectorTileApiKey=$VECTOR_TILE_API_KEY -PpeliasApiKey=$PELIAS_API_KEY -PvalhallaApiKey=$VALHALLA_API_KEY -PbuildNumber=$CIRCLE_BRANCH-$CIRCLE_BUILD_NUM
7+
./gradlew assembleDevDebug -PmintApiKey=$MINT_API_KEY -PvectorTileApiKey=$VECTOR_TILE_API_KEY -PpeliasApiKey=$PELIAS_API_KEY -PvalhallaApiKey=$VALHALLA_API_KEY -PbuildNumber=$CIRCLE_BRANCH-$CIRCLE_BUILD_NUM -PsearchBaseUrl="$SEARCH_BASE_URL" -ProuteBaseUrl="$ROUTE_BASE_URL"
88
s3cmd put app/build/outputs/apk/app-dev-debug.apk s3://android.mapzen.com/erasermap-development/$CIRCLE_BRANCH-$CIRCLE_BUILD_NUM.apk
99
else
1010
scripts/install-leyndo.sh
1111
cd app && git clone $CONFIG_REPO
1212
cd ..
13-
./gradlew clean assembleProdRelease --refresh-dependencies -PmintApiKey=$MINT_API_KEY -PvectorTileApiKey=$VECTOR_TILE_API_KEY_PROD -PpeliasApiKey=$PELIAS_API_KEY_PROD -PvalhallaApiKey=$VALHALLA_API_KEY_PROD -PbuildNumber=$RELEASE_TAG -PreleaseStoreFile=$RELEASE_STORE_FILE -PreleaseStorePassword="$RELEASE_STORE_PASSWORD" -PreleaseKeyAlias=$RELEASE_KEY_ALIAS -PreleaseKeyPassword="$RELEASE_KEY_PASSWORD"
13+
./gradlew clean assembleProdRelease --refresh-dependencies -PmintApiKey=$MINT_API_KEY -PvectorTileApiKey=$VECTOR_TILE_API_KEY_PROD -PpeliasApiKey=$PELIAS_API_KEY_PROD -PvalhallaApiKey=$VALHALLA_API_KEY_PROD -PbuildNumber=$RELEASE_TAG -PreleaseStoreFile=$RELEASE_STORE_FILE -PreleaseStorePassword="$RELEASE_STORE_PASSWORD" -PreleaseKeyAlias=$RELEASE_KEY_ALIAS -PreleaseKeyPassword="$RELEASE_KEY_PASSWORD" -PsearchBaseUrl="$SEARCH_BASE_URL" -ProuteBaseUrl="$ROUTE_BASE_URL"
1414
s3cmd put app/build/outputs/apk/app-prod-release.apk s3://android.mapzen.com/erasermap-releases/$RELEASE_TAG.apk
1515
fi

0 commit comments

Comments
 (0)