Update template adapted to company processes

This commit is contained in:
Vladimir 2020-04-17 17:10:54 +03:00
parent 9795f394aa
commit 18b07518c1
5 changed files with 78 additions and 62 deletions

@ -1 +1 @@
Subproject commit 51c48d55861d00bf5368790c1830a9ea726141c0
Subproject commit c957a38784af59fb341e3df651a60b0861aba50b

@ -1 +1 @@
Subproject commit 32c1f917039ef8cc505bbf7edeb10d6a250a5438
Subproject commit dc5cb987cfbc6ba37e59870650fae8c34b1a9c32

View File

@ -4,6 +4,8 @@ apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: 'com.google.firebase.crashlytics'
def customEndpoint = System.getenv("CUSTOM_ENDPOINT")
android {
compileSdkVersion versions.compileSdk
@ -59,8 +61,11 @@ android {
}
}
flavorDimensions "proguardSettings", "apiEndpoint"
flavorDimensions "proguardSettings", "apiEndpoint", "sslPinning", "testPanel"
/*
Use that guide for adding new server env. flavours https://github.com/TouchInstinct/Styleguide/blob/master/general/setupBuildGuide.md
*/
productFlavors {
noObfuscate {
dimension "proguardSettings"
@ -70,33 +75,29 @@ android {
dimension "proguardSettings"
proguardFiles getDefaultProguardFile('proguard-android.txt'), "$buildScriptsDir/proguard/obfuscate.pro"
}
mockDev {
dimension "apiEndpoint"
buildConfigField "String", "API_URL", '"https://template-mock.dev.touchin.ru/api/"'
}
mockTest {
dimension "apiEndpoint"
buildConfigField "String", "API_URL", '"https://template-mock.test.touchin.ru/api/"'
}
mockStage {
dimension "apiEndpoint"
buildConfigField "String", "API_URL", '"https://template-mock.stage.touchin.ru/api/"'
}
touchinDev {
dimension "apiEndpoint"
buildConfigField "String", "API_URL", '"https://template-middleware.dev.touchin.ru/api/"'
}
touchinTest {
def endpoint = customEndpoint ?: 'https://template-server.test.touchin.ru'
dimension "apiEndpoint"
buildConfigField "String", "API_URL", '"https://template-middleware.test.touchin.ru/api/"'
}
touchinStage {
dimension "apiEndpoint"
buildConfigField "String", "API_URL", '"https://template-middleware.stage.touchin.ru/api/"'
buildConfigField "String", "API_URL", """\"${endpoint}/\""""
}
customerProd {
def endpoint = customEndpoint ?: 'https://template-server.prod.customer.ru'
dimension "apiEndpoint"
buildConfigField "String", "API_URL", '"https://touchin.ru/api/"'
buildConfigField "String", "API_URL", """\"${endpoint}/\""""
}
withSSLPinning {
dimension "sslPinning"
buildConfigField "Boolean", "PIN_SSL", 'true'
}
withoutSSLPinning {
dimension "sslPinning"
buildConfigField "Boolean", "PIN_SSL", 'false'
}
withTestPanel {
dimension "testPanel"
}
withoutTestPanel {
dimension "testPanel"
}
}
@ -124,7 +125,7 @@ dependencies {
implementation "androidx.cardview:cardview:$versions.androidx"
implementation "androidx.gridlayout:gridlayout:$versions.androidx"
implementation "androidx.core:core-ktx:$versions.androidxKtx"
implementation "androidx.constraintlayout:constraintlayout:2.0.0-alpha2"
implementation "androidx.constraintlayout:constraintlayout:2.0.0-beta4"
implementation "com.google.android.material:material:$versions.material"
// Lifecycle
@ -159,6 +160,13 @@ dependencies {
implementation "com.github.bumptech.glide:okhttp3-integration:$versions.glide"
kapt "com.github.bumptech.glide:compiler:$versions.glide"
// Chucker
withTestPanelImplementation "com.github.ChuckerTeam.Chucker:library:$versions.chucker"
withoutTestPanelImplementation "com.github.ChuckerTeam.Chucker:library-no-op:$versions.chucker"
// LeakCanary
withTestPanelImplementation "com.squareup.leakcanary:leakcanary-android:$versions.leakcanary"
}
//TODO: uncomment, when common repo become plugged
@ -169,3 +177,4 @@ dependencies {
//apply from: "$buildScriptsDir/gradle/stringGenerator.gradle"
apply from: "$buildScriptsDir/gradle/staticAnalysis.gradle"
apply from: "$buildScriptsDir/gradle/apiGenerator.gradle"
apply from: "$buildScriptsDir/gradle/applicationFileNaming.gradle"

View File

@ -1,5 +1,7 @@
package ru.touchin.template.di.app.modules
import android.content.Context
import com.chuckerteam.chucker.api.ChuckerInterceptor
import com.touchin.template.BuildConfig
import dagger.Module
import dagger.Provides
@ -36,25 +38,26 @@ class NetworkModule {
@Singleton
@PublicApi
@Provides
fun providePublicClient(exceptionsInterceptor: ExceptionsInterceptor): OkHttpClient =
buildPublicClient(exceptionsInterceptor)
fun providePublicClient(context: Context, exceptionsInterceptor: ExceptionsInterceptor): OkHttpClient =
buildPublicClient(context, exceptionsInterceptor)
private fun buildRetrofitInstance(client: OkHttpClient, apiUrl: String): Retrofit = Retrofit.Builder()
.baseUrl(apiUrl)
.client(client)
.addCallAdapterFactory(CALL_ADAPTER_FACTORY)
.addConverterFactory(CONVERTER_FACTORY)
.build()
.baseUrl(apiUrl)
.client(client)
.addCallAdapterFactory(CALL_ADAPTER_FACTORY)
.addConverterFactory(CONVERTER_FACTORY)
.build()
private fun buildPublicClient(exceptionsInterceptor: ExceptionsInterceptor): OkHttpClient = OkHttpClient.Builder()
.apply {
connectTimeout(TIMEOUT, TimeUnit.SECONDS)
readTimeout(TIMEOUT, TimeUnit.SECONDS)
writeTimeout(TIMEOUT, TimeUnit.SECONDS)
addInterceptor(exceptionsInterceptor)
if (BuildConfig.DEBUG) {
addNetworkInterceptor(HttpLoggingInterceptor().apply { level = HttpLoggingInterceptor.Level.BODY })
}
}.build()
private fun buildPublicClient(context: Context, exceptionsInterceptor: ExceptionsInterceptor): OkHttpClient = OkHttpClient.Builder()
.apply {
connectTimeout(TIMEOUT, TimeUnit.SECONDS)
readTimeout(TIMEOUT, TimeUnit.SECONDS)
writeTimeout(TIMEOUT, TimeUnit.SECONDS)
addInterceptor(exceptionsInterceptor)
addInterceptor(ChuckerInterceptor(context))
if (BuildConfig.DEBUG) {
addNetworkInterceptor(HttpLoggingInterceptor().apply { level = HttpLoggingInterceptor.Level.BODY })
}
}.build()
}

View File

@ -1,7 +1,7 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.3.60'
ext.kotlin_version = '1.3.71'
ext.gradle_version = '3.5.2'
ext.fabric_version = '1.27.1'
repositories {
@ -13,9 +13,9 @@ buildscript {
dependencies {
classpath "com.android.tools.build:gradle:${gradle_version}"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'de.aaschmid:gradle-cpd-plugin:1.1'
classpath 'de.aaschmid:gradle-cpd-plugin:1.3'
classpath "io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.5.1"
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.0.0-beta02'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.0.0-beta04'
}
}
@ -35,21 +35,25 @@ task clean(type: Delete) {
ext {
buildScriptsDir = "$rootProject.projectDir/BuildScripts"
versions = [
compileSdk : 28,
androidx : '1.0.0',
fragment : '1.2.1',
appcompat : '1.0.2',
material : '1.0.0',
lifecycle : '2.2.0',
room : '2.0.0',
dagger : '2.17',
retrofit : '2.4.0',
okhttp3 : '3.14.1',
logansquare: '1.4.3',
rxJava : '2.2.3',
rxAndroid : '2.1.1',
firebaseCrashlytics : '17.0.0-beta01',
glide : '4.9.0',
location : '16.0.0'
compileSdk : 29,
androidx : '1.0.0',
fragment : '1.2.1',
appcompat : '1.1.0',
material : '1.1.0',
androidxKtx : '1.2.0',
lifecycle : '2.2.0',
room : '2.2.5',
dagger : '2.17',
retrofit : '2.4.0',
okhttp3 : '3.14.1',
logansquare : '1.4.3',
rxJava : '2.2.3',
rxAndroid : '2.1.1',
crashlytics : '2.10.1',
firebaseCrashlytics: '17.0.0-beta01',
glide : '4.11.0',
location : '16.0.0',
chucker : '3.1.1',
leakcanary : '2.1'
]
}