proton-mail-android/app/build.gradle.kts

304 lines
10 KiB
Plaintext
Raw Normal View History

2020-05-05 10:53:23 +00:00
/*
* Copyright (c) 2020 Proton Technologies AG
*
2020-05-05 10:53:23 +00:00
* This file is part of ProtonMail.
*
2020-05-05 10:53:23 +00:00
* ProtonMail is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
2020-05-05 10:53:23 +00:00
* ProtonMail is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
2020-05-05 10:53:23 +00:00
* You should have received a copy of the GNU General Public License
* along with ProtonMail. If not, see https://www.gnu.org/licenses/.
*/
import studio.forface.easygradle.dsl.*
import studio.forface.easygradle.dsl.android.*
import java.io.FileInputStream
import java.io.FileNotFoundException
import java.util.Properties
2020-05-05 10:53:23 +00:00
plugins {
`android-application`
`kotlin-android`
`kotlin-android-extensions`
`kotlin-kapt`
`kotlin-serialization`
`hugo`
`sentry-android`
`browserstack`
2020-05-05 10:53:23 +00:00
}
kapt {
correctErrorTypes = true
}
val privateProperties = Properties().apply {
try {
load(FileInputStream("privateConfig/private.properties"))
} catch (e: FileNotFoundException) {
put("sentryDNS_1", "")
put("sentryDNS_2", "")
put("safetyNet_apiKey", "")
put("b_endpointUrl", "")
put("d_endpointUrl", "")
put("h_endpointUrl", "")
put("pm_clientSecret", "")
}
2020-05-05 10:53:23 +00:00
}
val experimentalProperties = Properties().apply {
load(FileInputStream("experimental.properties"))
}
val adb = "${System.getenv("ANDROID_HOME")}/platform-tools/adb"
val browserstackUser = properties["BROWSERSTACK_USER"] ?: privateProperties["BROWSERSTACK_USER"]
val browserstackKey = properties["BROWSERSTACK_KEY"] ?: privateProperties["BROWSERSTACK_KEY"]
val testRecipient1 = properties["TEST_RECIPIENT1"] ?: privateProperties["TEST_RECIPIENT1"]
val testRecipient2 = properties["TEST_RECIPIENT2"] ?: privateProperties["TEST_RECIPIENT2"]
val testRecipient3 = properties["TEST_RECIPIENT3"] ?: privateProperties["TEST_RECIPIENT3"]
val testRecipient4 = properties["TEST_RECIPIENT4"] ?: privateProperties["TEST_RECIPIENT4"]
val testrailProjectId = properties["TESTRAIL_PROJECT_ID"] ?: privateProperties["TESTRAIL_PROJECT_ID"]
val testrailUsername = properties["TESTRAIL_USERNAME"] ?: privateProperties["TESTRAIL_USERNAME"]
val testrailPassword = properties["TESTRAIL_PASSWORD"] ?: privateProperties["TESTRAIL_PASSWORD"]
val testUser1 = properties["TEST_USER1"] ?: privateProperties["TEST_USER1"]
val testUser2 = properties["TEST_USER2"] ?: privateProperties["TEST_USER2"]
val testUser3 = properties["TEST_USER3"] ?: privateProperties["TEST_USER3"]
val testUser4 = properties["TEST_USER4"] ?: privateProperties["TEST_USER4"]
2020-05-05 10:53:23 +00:00
android(appIdSuffix = "android") {
useLibrary("org.apache.http.legacy")
flavorDimensions("default")
defaultConfig {
multiDexEnabled = true
// Private
2020-05-05 10:53:23 +00:00
buildConfigField("String", "SENTRY_DNS_1", "\"${privateProperties["sentryDNS_1"]}\"")
buildConfigField("String", "SENTRY_DNS_2", "\"${privateProperties["sentryDNS_2"]}\"")
buildConfigField("String", "SAFETY_NET_API_KEY", "\"${privateProperties["safetyNet_apiKey"]}\"")
buildConfigField("String", "B_ENDPOINT_URL", "\"${privateProperties["b_endpointUrl"]}\"")
buildConfigField("String", "D_ENDPOINT_URL", "\"${privateProperties["d_endpointUrl"]}\"")
buildConfigField("String", "H_ENDPOINT_URL", "\"${privateProperties["h_endpointUrl"]}\"")
buildConfigField("String", "PM_CLIENT_SECRET", "\"${privateProperties["pm_clientSecret"]}\"")
buildConfigField("String", "BROWSERSTACK_USER", browserstackUser.toString())
buildConfigField("String", "BROWSERSTACK_KEY", browserstackKey.toString())
buildConfigField("String", "TEST_RECIPIENT1", testRecipient1.toString())
buildConfigField("String", "TEST_RECIPIENT2", testRecipient2.toString())
buildConfigField("String", "TEST_RECIPIENT3", testRecipient3.toString())
buildConfigField("String", "TEST_RECIPIENT4", testRecipient4.toString())
buildConfigField("String", "TESTRAIL_PROJECT_ID", testrailProjectId.toString())
buildConfigField("String", "TESTRAIL_USERNAME", testrailUsername.toString())
buildConfigField("String", "TESTRAIL_PASSWORD", testrailPassword.toString())
buildConfigField("String", "TEST_USER1", testUser1.toString())
buildConfigField("String", "TEST_USER2", testUser2.toString())
buildConfigField("String", "TEST_USER3", testUser3.toString())
buildConfigField("String", "TEST_USER4", testUser4.toString())
2020-05-05 10:53:23 +00:00
// Experimental
buildConfigField("boolean", "EXPERIMENTAL_USERS_MANAGEMENT", "${experimentalProperties["users-management"]}")
2020-05-05 10:53:23 +00:00
buildConfigField("boolean", "FETCH_FULL_CONTACTS", "true")
buildConfigField("boolean", "REREGISTER_FOR_PUSH", "true")
buildConfigField("int", "ROOM_DB_VERSION", "${properties["DATABASE_VERSION"]}")
buildConfigField("boolean", "REPORT_TO_TESTRAIL", "false")
2020-05-05 10:53:23 +00:00
javaCompileOptions {
annotationProcessorOptions {
arguments["room.schemaLocation"] = "$projectDir/schemas"
}
}
}
signingConfigs {
register("release") {
if (privateProperties.getProperty("sentryDNS_1").isNotEmpty()) {
storeFile = file("$rootDir/privateConfig/keystore/ProtonMail.keystore")
storePassword = "${privateProperties["keyStorePassword"]}"
keyAlias = "ProtonMail"
keyPassword = "${privateProperties["keyStoreKeyPassword"]}"
}
2020-05-05 10:53:23 +00:00
}
}
productFlavors {
register("playstore") {
applicationId = "ch.protonmail.android"
}
register("beta") {
applicationId = "ch.protonmail.android.beta"
}
}
buildTypes {
all {
archivesBaseName = "ProtonMail-Android-${android.defaultConfig.versionName}"
multiDexKeepProguard = File("multidex-proguard.pro")
}
getByName("debug") {
isMinifyEnabled = false
}
getByName("releasePlayStore") {
isMinifyEnabled = true
proguardFiles(getDefaultProguardFile("proguard-android.txt"), File("proguard-rules.pro"))
signingConfig = signingConfigs["release"]
}
getByName("releaseBeta") {
isMinifyEnabled = true
proguardFiles(getDefaultProguardFile("proguard-android.txt"), File("proguard-rules.pro"))
signingConfig = signingConfigs["release"]
2020-05-05 10:53:23 +00:00
}
}
packagingOptions {
exclude("META-INF/INDEX.LIST")
}
2020-05-05 10:53:23 +00:00
}
browserStackConfig {
username = browserstackUser.toString().replace("\"", "")
accessKey = browserstackKey.toString().replace("\"", "")
configFilePath = "./app/src/uiTest/kotlin/ch/protonmail/android/uitests/testsHelper/browserstack_config.json"
}
// Clear app data each time you run tests locally once before the run. Should be added in IDE run configuration.
tasks.register("clearData", Exec::class) {
commandLine(adb, "shell", "pm", "clear", "ch.protonmail.android.beta")
}
// Run as ch.protonmail.android.beta and copy test artifacts to sdcard/Download location
tasks.register("copyArtifacts", Exec::class) {
commandLine(
adb,
"shell",
"run-as",
"ch.protonmail.android.beta",
"cp",
"-R",
"./files/artifacts/",
"/sdcard/Download/"
)
}
tasks.register("pullTestArtifacts", Exec::class) {
dependsOn("copyArtifacts")
commandLine(adb, "pull", "/sdcard/Download/artifacts")
}
2020-05-05 10:53:23 +00:00
dependencies {
// Kapt
kapt(
`butterknife-compiler`,
`dagger-compiler`,
`dagger-android-processor`,
`room-compiler`
)
kaptTest(`dagger-compiler`)
// Dagger modules
// These dependency can be resolved at compile-time only.
// We should not use include any of them in the run-time of this module, we need this dependency for of being able
// to build the Dagger's dependency graph
compileOnly(
project(Module.credentials)
)
2020-05-05 10:53:23 +00:00
implementation(
// Core
rootProject.aar(Lib.protonCore, version = `old protonCore version`),
// rootProject.aar(Lib.composer, version = `composer version`),
`Proton-kotlin-util`,
`Proton-shared-preferences`,
`Proton-domain`,
`Proton-work-manager`,
// Modules
project(Module.domain),
// project(Module.tokenAutoComplete),
2020-05-05 10:53:23 +00:00
// Kotlin
`kotlin-jdk7`,
`kotlin-reflect`,
`coroutines-android`,
`serialization`,
// Android
`android-annotation`,
`appcompat`,
`android-biometric`,
`constraint-layout`,
`android-fragment`,
`android-ktx`,
`android-media`,
`material`,
`paging-runtime`,
`android-work-runtime`,
// Lifecycle
`lifecycle-extensions`,
`lifecycle-runtime`,
`lifecycle-liveData`,
`lifecycle-viewModel`,
// Room
`room-runtime`,
`room-ktx`,
`room-rxJava`,
// Dagger
`dagger-android`,
`dagger-android-support`,
// Retrofit
`retrofit`,
`retrofit-gson`,
`retrofit-rxJava`,
`okHttp-loggingInterceptor`,
// RxJava
`rxJava-android`,
`rxRelay`,
// Other
`apache-commons-lang`,
`butterknife-runtime`,
`gcm`,
`gson`,
`hugo-annotations`,
`jsoup`,
`safetyNet`,
`sentry-android`,
`stetho`,
`timber`,
`trustKit`,
`viewStateStore`,
`viewStateStore-paging`,
`minidns`,
`retrofit2-converter`,
`fasterxml-jackson-core`,
`fasterxml-jackson-anno`,
`fasterxml-jackson-databind`
2020-05-05 10:53:23 +00:00
)
testImplementation(project(Module.testAndroid))
androidTestUtil(`orchestrator`)
androidTestImplementation(
project(Module.testAndroidInstrumented),
`aerogear`,
`falcon`,
`espresso-contrib`,
`espresso-intents`,
`uiautomator`
)
2020-05-05 10:53:23 +00:00
}
apply(from = "old.build.gradle")