Add staging build variant, move staging URL out of source control
Change-Id: I9388f8d2adc4800749fc7e5e79c2d165938401c4
This commit is contained in:
@@ -37,6 +37,9 @@ android {
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
val debug by getting {
|
||||
applicationIdSuffix = ".debug"
|
||||
}
|
||||
val release by getting {
|
||||
isMinifyEnabled = true
|
||||
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
|
||||
@@ -47,6 +50,12 @@ android {
|
||||
matchingFallbacks.add("release")
|
||||
proguardFiles("benchmark-rules.pro")
|
||||
}
|
||||
val staging by creating {
|
||||
initWith(debug)
|
||||
signingConfig = signingConfigs.getByName("debug")
|
||||
matchingFallbacks.add("debug")
|
||||
applicationIdSuffix = ".staging"
|
||||
}
|
||||
}
|
||||
packagingOptions {
|
||||
resources {
|
||||
|
||||
@@ -25,5 +25,6 @@ buildscript {
|
||||
classpath(libs.kotlin.gradlePlugin)
|
||||
classpath(libs.kotlin.serializationPlugin)
|
||||
classpath(libs.hilt.gradlePlugin)
|
||||
classpath(libs.secrets.gradlePlugin)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,27 @@ plugins {
|
||||
id("kotlinx-serialization")
|
||||
id("dagger.hilt.android.plugin")
|
||||
id("nowinandroid.spotless")
|
||||
id("com.google.android.libraries.mapsplatform.secrets-gradle-plugin")
|
||||
}
|
||||
|
||||
android {
|
||||
buildTypes {
|
||||
val staging by creating {
|
||||
initWith(getByName("debug"))
|
||||
matchingFallbacks.add("debug")
|
||||
}
|
||||
}
|
||||
// Force the staging variant to use the release source directory. This is necessary so that the
|
||||
// staging variant uses the remote network.
|
||||
sourceSets {
|
||||
getByName("staging") {
|
||||
java.srcDir("src/release/java")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
secrets {
|
||||
defaultPropertiesFileName = "secrets.defaults.properties"
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright 2022 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.google.samples.apps.nowinandroid.core.network.di
|
||||
|
||||
import com.google.samples.apps.nowinandroid.core.network.NiANetwork
|
||||
import com.google.samples.apps.nowinandroid.core.network.fake.FakeNiANetwork
|
||||
import dagger.Binds
|
||||
import dagger.Module
|
||||
import dagger.Provides
|
||||
import dagger.hilt.InstallIn
|
||||
import dagger.hilt.components.SingletonComponent
|
||||
import javax.inject.Singleton
|
||||
import kotlinx.serialization.json.Json
|
||||
|
||||
@Module
|
||||
@InstallIn(SingletonComponent::class)
|
||||
interface NetworkModule {
|
||||
|
||||
@Binds
|
||||
fun bindsNiANetwork(
|
||||
niANetwork: FakeNiANetwork
|
||||
): NiANetwork
|
||||
|
||||
companion object {
|
||||
@Provides
|
||||
@Singleton
|
||||
fun providesNetworkJson(): Json = Json {
|
||||
ignoreUnknownKeys = true
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.google.samples.apps.nowinandroid.core.network.retrofit
|
||||
|
||||
import com.google.samples.apps.nowinandroid.core.network.BuildConfig
|
||||
import com.google.samples.apps.nowinandroid.core.network.NiANetwork
|
||||
import com.google.samples.apps.nowinandroid.core.network.model.NetworkAuthor
|
||||
import com.google.samples.apps.nowinandroid.core.network.model.NetworkChangeList
|
||||
@@ -68,7 +69,7 @@ private interface RetrofitNiANetworkApi {
|
||||
): List<NetworkChangeList>
|
||||
}
|
||||
|
||||
private const val NiABaseUrl = "https://staging-url.com/"
|
||||
private const val NiABaseUrl = BuildConfig.BACKEND_URL
|
||||
|
||||
/**
|
||||
* Wrapper for data provided from the [NiABaseUrl]
|
||||
|
||||
@@ -41,6 +41,7 @@ protobufPlugin = "0.8.18"
|
||||
retrofit = "2.9.0"
|
||||
retrofitKotlinxSerializationJson = "0.8.0"
|
||||
room = "2.4.1"
|
||||
secrets = "2.0.1"
|
||||
spotless = "6.3.0"
|
||||
turbine = "0.7.0"
|
||||
|
||||
@@ -108,6 +109,7 @@ retrofit-kotlin-serialization = { group = "com.jakewharton.retrofit", name = "re
|
||||
room-runtime = { group = "androidx.room", name = "room-runtime", version.ref = "room" }
|
||||
room-ktx = { group = "androidx.room", name = "room-ktx", version.ref = "room" }
|
||||
room-compiler = { group = "androidx.room", name = "room-compiler", version.ref = "room" }
|
||||
secrets-gradlePlugin = { group = "com.google.android.libraries.mapsplatform.secrets-gradle-plugin", name = "secrets-gradle-plugin", version.ref = "secrets" }
|
||||
spotless-gradlePlugin = { group = "com.diffplug.spotless", name = "spotless-plugin-gradle", version.ref = "spotless" }
|
||||
|
||||
[plugins]
|
||||
|
||||
4
secrets.defaults.properties
Normal file
4
secrets.defaults.properties
Normal file
@@ -0,0 +1,4 @@
|
||||
## This file provides default values to modules using the secrets-gradle-plugin. It is necessary
|
||||
# because the secrets properties file is not under source control so CI builds will fail without
|
||||
# default values.
|
||||
BACKEND_URL="http://example.com"
|
||||
Reference in New Issue
Block a user