New build config
This commit is contained in:
parent
e1671eb337
commit
bb191d61dd
|
@ -6,8 +6,8 @@ before_script:
|
|||
- echo -e "y\ny\ny\ny\ny\ny\ny\ny\n" | $ANDROID_HOME/tools/bin/sdkmanager --licenses --proxy=http --proxy_host=$( echo ${https_proxy##http://} | cut -d':' -f1 ) --proxy_port=$( echo ${https_proxy##http://} | cut -d':' -f2 )
|
||||
- export GRADLE_USER_HOME=`pwd`/.gradle
|
||||
- chmod +x ./gradlew
|
||||
- export VERSION_NAME=$(grep -E "versionName " app/build.gradle | awk '{print $3}' | sed s/\"//g)
|
||||
- export VERSION_CODE=$(grep -E "versionCode " app/build.gradle | awk '{print $3}' | sed s/\"//g)
|
||||
- export VERSION_NAME=$(grep -E "versionName " buildSrc/src/main/kotlin/Project.kt | awk '{print $3}' | sed s/\"//g)
|
||||
- export VERSION_CODE=$(grep -E "versionCode " buildSrc/src/main/kotlin/Project.kt | awk '{print $3}' | sed s/\"//g)
|
||||
- echo "App version name ${VERSION_NAME}"
|
||||
- echo "App version name ${VERSION_CODE}"
|
||||
cache:
|
||||
|
@ -35,7 +35,7 @@ detekt analysis:
|
|||
- ./gradlew detekt
|
||||
artifacts:
|
||||
reports:
|
||||
codequality: app/build/reports/detekt.json
|
||||
codequality: reports/detekt.json
|
||||
|
||||
build debug:
|
||||
stage: build
|
||||
|
|
290
app/build.gradle
290
app/build.gradle
|
@ -1,290 +0,0 @@
|
|||
import Plugin
|
||||
import Project
|
||||
import Module
|
||||
|
||||
apply plugin: Plugin.android_application.id
|
||||
apply plugin: Plugin.kotlin_android.id
|
||||
apply plugin: Plugin.kapt.id
|
||||
apply plugin: Plugin.kotlin_android_extensions.id
|
||||
apply plugin: Plugin.hugo.id
|
||||
apply plugin: Plugin.sentry.id
|
||||
apply plugin: 'io.gitlab.arturbosch.detekt'
|
||||
|
||||
def databaseVersion = 1
|
||||
|
||||
detekt {
|
||||
failFast = false
|
||||
config = files("$rootDir/detekt/config.yml")
|
||||
|
||||
reports {
|
||||
xml {
|
||||
enabled = false
|
||||
}
|
||||
html {
|
||||
enabled = false
|
||||
}
|
||||
txt {
|
||||
enabled = false
|
||||
}
|
||||
custom {
|
||||
reportId = "DetektQualityOutputReport"
|
||||
destination = file("build/reports/detekt.json")
|
||||
}
|
||||
}
|
||||
}
|
||||
configurations {
|
||||
detekt
|
||||
}
|
||||
|
||||
dependencies {
|
||||
// region libs
|
||||
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
||||
implementation project(':gopenpgp')
|
||||
implementation files('libs/commons-email-1.3.jar')
|
||||
implementation files('libs/mail.jar')
|
||||
implementation files('libs/mail-additional.jar')
|
||||
implementation files('libs/mail-activation.jar')
|
||||
|
||||
implementation files('libs/Proton-core_0.2.15.aar')
|
||||
// endregion
|
||||
|
||||
// region Android
|
||||
implementation LibAndroid.get.annotations
|
||||
implementation LibAndroid.get.appcompat
|
||||
implementation LibAndroid.get.biometric
|
||||
implementation LibAndroid.get.constraintLayout
|
||||
implementation LibAndroid.get.ktx
|
||||
implementation LibAndroid.get.material
|
||||
implementation LibAndroid.get.paging
|
||||
implementation LibAndroid.get.work
|
||||
|
||||
// region Lifecycle
|
||||
implementation LibAndroid.get.lifecycle_extensions // TODO for some weird reason, after updating WorkManager '2.0.1' -> '2.1.0-beta01' `ViewModelProviders` is not resolved anymore, but we don't really need this dependency, since we already have 'runtime', 'livedata-ktx' and 'viewmodel-ktx'
|
||||
implementation LibAndroid.get.lifecycle_runtime
|
||||
implementation LibAndroid.get.lifecycle_liveData
|
||||
implementation LibAndroid.get.lifecycle_viewModel
|
||||
// endregion
|
||||
|
||||
// region Room
|
||||
implementation LibAndroid.get.room_runtime
|
||||
implementation LibAndroid.get.room_ktx
|
||||
implementation LibAndroid.get.room_rxJava
|
||||
kapt LibAndroid.get.room_compiler
|
||||
// endregion
|
||||
|
||||
// endregion
|
||||
|
||||
//region Dagger
|
||||
implementation Lib.dagger_android
|
||||
implementation Lib.dagger_androidSupport
|
||||
kapt Lib.dagger_compiler
|
||||
kapt Lib.dagger_androidProcessor
|
||||
//endregion
|
||||
|
||||
// region Kotlin
|
||||
implementation Lib.kotlin
|
||||
implementation Lib.reflect
|
||||
implementation Lib.coroutines_android
|
||||
// endregion
|
||||
|
||||
//region Retrofit and OkHttp
|
||||
implementation Lib.retrofit
|
||||
implementation Lib.retrofit_gson
|
||||
implementation Lib.retrofit_rxJava
|
||||
implementation Lib.okHttp_loggingInterceptor
|
||||
//endregion
|
||||
|
||||
// region RxJava
|
||||
implementation Lib.rxJava_android
|
||||
implementation Lib.rxRelay
|
||||
// endregion
|
||||
|
||||
// region Others
|
||||
implementation Lib.butterKnife
|
||||
kapt Lib.butterKnife_compiler
|
||||
implementation Lib.gson
|
||||
implementation Lib.hugo_annotations
|
||||
implementation Lib.stetho
|
||||
implementation Lib.trustKit
|
||||
implementation Lib.viewStateStore
|
||||
implementation Lib.viewStateStore_paging
|
||||
implementation Lib.timber
|
||||
implementation Lib.sentry
|
||||
// implementation project(Module.tokenAutoComplete)
|
||||
implementation "com.splitwise:tokenautocomplete:2.0.8"
|
||||
// endregion
|
||||
|
||||
compileOnly 'org.glassfish:javax.annotation:10.0-b28'
|
||||
configurations.all {
|
||||
exclude group: 'com.android.support', module: 'support-v13'
|
||||
}
|
||||
|
||||
detekt 'io.gitlab.arturbosch.detekt:detekt-cli:1.8.0'
|
||||
detektPlugins 'pm.algirdas.detekt:codeanalysis:0.2.2'
|
||||
detektPlugins 'io.gitlab.arturbosch.detekt:detekt-formatting:1.8.0'
|
||||
|
||||
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
|
||||
implementation 'androidx.media:media:1.1.0-alpha04'
|
||||
implementation 'androidx.cardview:cardview:1.0.0'
|
||||
implementation 'androidx.multidex:multidex:2.0.1'
|
||||
implementation 'com.squareup:otto:1.3.8'
|
||||
implementation 'com.birbit:android-priority-jobqueue:2.0.1'
|
||||
implementation 'com.google.android.gms:play-services-gcm:17.0.0'
|
||||
implementation 'com.atlassian.commonmark:commonmark:0.13.0'
|
||||
implementation 'org.apache.commons:commons-lang3:3.4'
|
||||
implementation 'com.github.JakeWharton:ViewPagerIndicator:2.4.1'
|
||||
implementation 'org.jsoup:jsoup:1.8.3'
|
||||
// implementation 'com.commonsware.cwac:wakeful:1.1.0'
|
||||
implementation 'com.badoo.mobile:android-weak-handler:1.0'
|
||||
implementation 'com.google.code.findbugs:jsr305:3.0.2'
|
||||
implementation 'com.wdullaer:materialdatetimepicker:3.2.2'
|
||||
implementation group: 'at.favre.lib', name: 'bcrypt', version: '0.9.0'
|
||||
implementation 'com.fasterxml.jackson.core:jackson-databind:2.9.0'
|
||||
implementation('com.googlecode.ez-vcard:ez-vcard:0.10.3') {
|
||||
// hCard functionality not needed
|
||||
exclude group: 'org.jsoup'
|
||||
exclude group: 'org.freemarker'
|
||||
// jCard functionality not needed
|
||||
exclude group: 'com.fasterxml.jackson.core'
|
||||
}
|
||||
implementation 'com.google.android.gms:play-services-safetynet:17.0.0'
|
||||
implementation 'io.sentry:sentry-android:1.7.22'
|
||||
implementation 'androidx.lifecycle:lifecycle-extensions:2.1.0-alpha04'
|
||||
|
||||
implementation 'com.github.clans:fab:1.6.4'
|
||||
|
||||
testImplementation project(Module.testAndroid)
|
||||
androidTestImplementation project(Module.testAndroidInstrumented)
|
||||
}
|
||||
|
||||
file("$rootDir/privateConfig/private.properties").withReader {
|
||||
Properties props = new Properties()
|
||||
props.load(it)
|
||||
project.ext.privateProperties = props
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdkVersion Project.targetSdk
|
||||
buildToolsVersion '28.0.3'
|
||||
useLibrary 'org.apache.http.legacy'
|
||||
|
||||
flavorDimensions 'default'
|
||||
|
||||
defaultConfig {
|
||||
applicationId "ch.protonmail.android"
|
||||
minSdkVersion Project.minSdk
|
||||
targetSdkVersion Project.targetSdk
|
||||
versionCode = 719 // jenkinsBuildNumber.toInteger()
|
||||
versionName = "1.13.4"
|
||||
|
||||
multiDexEnabled true
|
||||
vectorDrawables.useSupportLibrary = true
|
||||
|
||||
// Sensitive data
|
||||
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 "boolean", "FETCH_FULL_CONTACTS", "true"
|
||||
buildConfigField "boolean", "REREGISTER_FOR_PUSH", "true"
|
||||
buildConfigField "int", "ROOM_DB_VERSION", "${databaseVersion}"
|
||||
|
||||
javaCompileOptions {
|
||||
annotationProcessorOptions {
|
||||
arguments = ["room.schemaLocation": "$projectDir/schemas".toString()]
|
||||
}
|
||||
}
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
|
||||
signingConfigs {
|
||||
release {
|
||||
storeFile file("../privateConfig/keystore/ProtonMail.keystore")
|
||||
storePassword privateProperties.keyStorePassword
|
||||
keyAlias "ProtonMail"
|
||||
keyPassword privateProperties.keyStoreKeyPassword
|
||||
}
|
||||
}
|
||||
|
||||
productFlavors {
|
||||
playstore {
|
||||
applicationId "ch.protonmail.android"
|
||||
}
|
||||
beta {
|
||||
applicationId "ch.protonmail.android.beta"
|
||||
}
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
all {
|
||||
project.ext.set('archivesBaseName', 'ProtonMail-Android-' + android.defaultConfig.versionName)
|
||||
multiDexKeepProguard file('multidex-proguard.pro')
|
||||
}
|
||||
debug {
|
||||
minifyEnabled false
|
||||
multiDexKeepProguard file('multidex-proguard.pro')
|
||||
}
|
||||
releasePlayStore {
|
||||
minifyEnabled true
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
multiDexKeepProguard file('multidex-proguard.pro')
|
||||
signingConfig signingConfigs.release
|
||||
}
|
||||
releaseBeta {
|
||||
minifyEnabled true
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
multiDexKeepProguard file('multidex-proguard.pro')
|
||||
signingConfig signingConfigs.release
|
||||
}
|
||||
}
|
||||
|
||||
lintOptions {
|
||||
disable 'InvalidPackage', 'MissingTranslation', 'ExtraTranslation'
|
||||
}
|
||||
sourceSets {
|
||||
main {
|
||||
assets.srcDirs = ['src/main/assets', 'src/main/assets/']
|
||||
// res.srcDirs = ['src/main/res', 'src/main/res/raw']
|
||||
jni.srcDirs = []
|
||||
}
|
||||
}
|
||||
|
||||
packagingOptions {
|
||||
exclude 'META-INF/DEPENDENCIES.txt'
|
||||
exclude 'META-INF/LICENSE.txt'
|
||||
exclude 'META-INF/NOTICE.txt'
|
||||
exclude 'META-INF/NOTICE'
|
||||
exclude 'META-INF/LICENSE'
|
||||
exclude 'META-INF/LICENSE.md'
|
||||
exclude 'META-INF/LICENSE-notice.md'
|
||||
exclude 'META-INF/DEPENDENCIES'
|
||||
exclude 'META-INF/notice.txt'
|
||||
exclude 'META-INF/license.txt'
|
||||
exclude 'META-INF/dependencies.txt'
|
||||
exclude 'META-INF/LGPL2.1'
|
||||
exclude 'META-INF/rxjava.properties'
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
}
|
||||
|
||||
sentry {
|
||||
// Disables or enables the automatic configuration of proguard
|
||||
// for Sentry. This injects a default config for proguard so
|
||||
// you don't need to do it manually.
|
||||
autoProguardConfig true
|
||||
|
||||
// Enables or disables the automatic upload of mapping files
|
||||
// during a build. If you disable this you'll need to manually
|
||||
// upload the mapping files with sentry-cli when you do a release.
|
||||
autoUpload true
|
||||
}
|
||||
|
|
@ -0,0 +1,206 @@
|
|||
/*
|
||||
* Copyright (c) 2020 Proton Technologies AG
|
||||
*
|
||||
* This file is part of ProtonMail.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with ProtonMail. If not, see https://www.gnu.org/licenses/.
|
||||
*/
|
||||
import java.io.FileInputStream
|
||||
import java.util.*
|
||||
import studio.forface.easygradle.dsl.*
|
||||
import studio.forface.easygradle.dsl.android.*
|
||||
|
||||
plugins {
|
||||
`android-application`
|
||||
`detekt`
|
||||
`kotlin-android`
|
||||
`kotlin-android-extensions`
|
||||
`kotlin-kapt`
|
||||
`kotlin-serialization`
|
||||
`hugo`
|
||||
`sentry-android`
|
||||
}
|
||||
|
||||
kapt {
|
||||
correctErrorTypes = true
|
||||
}
|
||||
|
||||
detekt {
|
||||
failFast = false
|
||||
config = files("$rootDir/detekt/config.yml")
|
||||
|
||||
reports {
|
||||
xml.enabled = false
|
||||
html.enabled = false
|
||||
txt.enabled = false
|
||||
custom {
|
||||
reportId = "DetektQualityOutputReport"
|
||||
destination = file("$rootDir/detekt/report.json")
|
||||
}
|
||||
}
|
||||
}
|
||||
configurations { detekt }
|
||||
|
||||
val privateProperties = Properties().apply {
|
||||
load(FileInputStream("privateConfig/private.properties"))
|
||||
}
|
||||
|
||||
android(appIdSuffix = "android") {
|
||||
|
||||
useLibrary("org.apache.http.legacy")
|
||||
flavorDimensions("default")
|
||||
|
||||
defaultConfig {
|
||||
multiDexEnabled = true
|
||||
|
||||
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("boolean", "FETCH_FULL_CONTACTS", "true")
|
||||
buildConfigField("boolean", "REREGISTER_FOR_PUSH", "true")
|
||||
buildConfigField("int", "ROOM_DB_VERSION", "${properties["DATABASE_VERSION"]}")
|
||||
|
||||
javaCompileOptions {
|
||||
annotationProcessorOptions {
|
||||
arguments["room.schemaLocation"] = "$projectDir/schemas"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
signingConfigs {
|
||||
register("release") {
|
||||
keyAlias = "ProtonMail"
|
||||
}
|
||||
}
|
||||
|
||||
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"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(
|
||||
rootProject.aar(Lib.protonCore, version = `protonCore version`)
|
||||
// rootProject.aar(Lib.composer, version = `composer version`),
|
||||
// project(Module.tokenAutoComplete)
|
||||
)
|
||||
|
||||
// Kapt
|
||||
kapt(
|
||||
`butterknife-compiler`,
|
||||
`dagger-compiler`,
|
||||
`dagger-android-processor`,
|
||||
`room-compiler`
|
||||
)
|
||||
kaptTest(`dagger-compiler`)
|
||||
|
||||
implementation(
|
||||
// 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`
|
||||
)
|
||||
|
||||
testImplementation(project(Module.testAndroid))
|
||||
androidTestImplementation(project(Module.testAndroidInstrumented))
|
||||
|
||||
// Detekt
|
||||
detekt(`detekt-cli`)
|
||||
detektPlugins(`detekt-code-analysis`)
|
||||
detektPlugins(`detekt-formatting`)
|
||||
}
|
||||
|
||||
apply(from = "old.build.gradle")
|
|
@ -0,0 +1,58 @@
|
|||
// TODO: remove useless libs and organise others in `build.gradle.kts` following the proper pattern
|
||||
dependencies {
|
||||
// region libs
|
||||
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
||||
implementation project(':gopenpgp')
|
||||
implementation files('libs/commons-email-1.3.jar')
|
||||
implementation files('libs/mail.jar')
|
||||
implementation files('libs/mail-additional.jar')
|
||||
implementation files('libs/mail-activation.jar')
|
||||
// endregion
|
||||
|
||||
compileOnly 'org.glassfish:javax.annotation:10.0-b28'
|
||||
configurations.all {
|
||||
exclude group: 'com.android.support', module: 'support-v13'
|
||||
}
|
||||
|
||||
implementation "com.splitwise:tokenautocomplete:2.0.8"
|
||||
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
|
||||
implementation 'com.squareup:otto:1.3.8'
|
||||
implementation 'com.birbit:android-priority-jobqueue:2.0.1'
|
||||
implementation 'com.atlassian.commonmark:commonmark:0.13.0'
|
||||
implementation 'com.github.JakeWharton:ViewPagerIndicator:2.4.1'
|
||||
// implementation 'com.commonsware.cwac:wakeful:1.1.0'
|
||||
implementation 'com.badoo.mobile:android-weak-handler:1.0'
|
||||
implementation 'com.google.code.findbugs:jsr305:3.0.2'
|
||||
implementation 'com.wdullaer:materialdatetimepicker:3.2.2'
|
||||
implementation group: 'at.favre.lib', name: 'bcrypt', version: '0.9.0'
|
||||
implementation 'com.fasterxml.jackson.core:jackson-databind:2.9.0'
|
||||
implementation('com.googlecode.ez-vcard:ez-vcard:0.10.3') {
|
||||
// hCard functionality not needed
|
||||
exclude group: 'org.jsoup'
|
||||
exclude group: 'org.freemarker'
|
||||
// jCard functionality not needed
|
||||
exclude group: 'com.fasterxml.jackson.core'
|
||||
}
|
||||
|
||||
implementation 'com.github.clans:fab:1.6.4'
|
||||
}
|
||||
|
||||
// TODO: remove if not needed
|
||||
//android {
|
||||
//
|
||||
// packagingOptions {
|
||||
// exclude 'META-INF/DEPENDENCIES.txt'
|
||||
// exclude 'META-INF/LICENSE.txt'
|
||||
// exclude 'META-INF/NOTICE.txt'
|
||||
// exclude 'META-INF/NOTICE'
|
||||
// exclude 'META-INF/LICENSE'
|
||||
// exclude 'META-INF/LICENSE.md'
|
||||
// exclude 'META-INF/LICENSE-notice.md'
|
||||
// exclude 'META-INF/DEPENDENCIES'
|
||||
// exclude 'META-INF/notice.txt'
|
||||
// exclude 'META-INF/license.txt'
|
||||
// exclude 'META-INF/dependencies.txt'
|
||||
// exclude 'META-INF/LGPL2.1'
|
||||
// exclude 'META-INF/rxjava.properties'
|
||||
// }
|
||||
//}
|
|
@ -20,8 +20,9 @@ package ch.protonmail.android.api.models.room.counters
|
|||
|
||||
import androidx.arch.core.executor.testing.InstantTaskExecutorRule
|
||||
import androidx.room.Room
|
||||
import androidx.test.InstrumentationRegistry
|
||||
import androidx.test.core.app.ApplicationProvider
|
||||
import ch.protonmail.android.api.models.room.testValue
|
||||
import ch.protonmail.android.core.ProtonMailApplication
|
||||
import ch.protonmail.android.testAndroidInstrumented.ReflectivePropertiesMatcher
|
||||
import ch.protonmail.android.testAndroidInstrumented.matchers
|
||||
import org.hamcrest.Matchers.`is`
|
||||
|
@ -35,270 +36,271 @@ import org.junit.Test
|
|||
* Created by Kamil Rajtar on 05.09.18. */
|
||||
internal class CountersDatabaseTest {
|
||||
|
||||
private val context = InstrumentationRegistry.getTargetContext()
|
||||
private var databaseFactory = Room.inMemoryDatabaseBuilder(context, CountersDatabaseFactory::class.java).build()
|
||||
private var database = databaseFactory.getDatabase()
|
||||
@get:Rule
|
||||
var instantTaskExecutorRule = InstantTaskExecutorRule()
|
||||
private val context = ApplicationProvider.getApplicationContext<ProtonMailApplication>()
|
||||
private var databaseFactory = Room.inMemoryDatabaseBuilder(context, CountersDatabaseFactory::class.java).build()
|
||||
private var database = databaseFactory.getDatabase()
|
||||
|
||||
private val unreadLocations=listOf(
|
||||
UnreadLocationCounter(1,5),
|
||||
UnreadLocationCounter(2,7),
|
||||
UnreadLocationCounter(3,2),
|
||||
UnreadLocationCounter(4,12)
|
||||
)
|
||||
@get:Rule
|
||||
var instantTaskExecutorRule = InstantTaskExecutorRule()
|
||||
|
||||
private val unreadLabels=listOf(
|
||||
UnreadLabelCounter("a",5),
|
||||
UnreadLabelCounter("b",7),
|
||||
UnreadLabelCounter("c",2),
|
||||
UnreadLabelCounter("d",12)
|
||||
)
|
||||
private val unreadLocations = listOf(
|
||||
UnreadLocationCounter(1, 5),
|
||||
UnreadLocationCounter(2, 7),
|
||||
UnreadLocationCounter(3, 2),
|
||||
UnreadLocationCounter(4, 12)
|
||||
)
|
||||
|
||||
private val totalLocations=listOf(
|
||||
TotalLocationCounter(1,5),
|
||||
TotalLocationCounter(2,7),
|
||||
TotalLocationCounter(3,2),
|
||||
TotalLocationCounter(4,12)
|
||||
)
|
||||
private val totalLabels=listOf(
|
||||
TotalLabelCounter("a",5),
|
||||
TotalLabelCounter("b",7),
|
||||
TotalLabelCounter("c",2),
|
||||
TotalLabelCounter("d",12)
|
||||
)
|
||||
private val unreadLabels = listOf(
|
||||
UnreadLabelCounter("a", 5),
|
||||
UnreadLabelCounter("b", 7),
|
||||
UnreadLabelCounter("c", 2),
|
||||
UnreadLabelCounter("d", 12)
|
||||
)
|
||||
|
||||
private fun assertDatabaseState(expectedUnreadLocations:Iterable<UnreadLocationCounter> =unreadLocations,
|
||||
expectedUnreadLabels:Iterable<UnreadLabelCounter> =unreadLabels,
|
||||
expectedTotalLocations:Iterable<TotalLocationCounter> =totalLocations,
|
||||
expectedTotalLabels:Iterable<TotalLabelCounter> =totalLabels) {
|
||||
val expectedUnreadLocationsMatcher=
|
||||
expectedUnreadLocations.map {ReflectivePropertiesMatcher(it)}
|
||||
val expectedUnreadLabelsMatcher=expectedUnreadLabels.map {ReflectivePropertiesMatcher(it)}
|
||||
val expectedTotalLocationsMatcher=
|
||||
expectedTotalLocations.map {ReflectivePropertiesMatcher(it)}
|
||||
val expectedTotalLabelsMatcher=expectedTotalLabels.map {ReflectivePropertiesMatcher(it)}
|
||||
private val totalLocations = listOf(
|
||||
TotalLocationCounter(1, 5),
|
||||
TotalLocationCounter(2, 7),
|
||||
TotalLocationCounter(3, 2),
|
||||
TotalLocationCounter(4, 12)
|
||||
)
|
||||
private val totalLabels = listOf(
|
||||
TotalLabelCounter("a", 5),
|
||||
TotalLabelCounter("b", 7),
|
||||
TotalLabelCounter("c", 2),
|
||||
TotalLabelCounter("d", 12)
|
||||
)
|
||||
|
||||
val actualUnreadLocationsSet=database.findAllUnreadLocations().testValue
|
||||
val actualUnreadLabelsSet=database.findAllUnreadLabels().testValue
|
||||
val actualTotalLocationsSet=database.findAllTotalLocations().testValue
|
||||
val actualTotalLabelsSet=database.findAllTotalLabels().testValue
|
||||
Assert.assertThat(actualUnreadLocationsSet,
|
||||
containsInAnyOrder(expectedUnreadLocationsMatcher))
|
||||
Assert.assertThat(actualUnreadLabelsSet,containsInAnyOrder(expectedUnreadLabelsMatcher))
|
||||
Assert.assertThat(actualTotalLocationsSet,containsInAnyOrder(expectedTotalLocationsMatcher))
|
||||
Assert.assertThat(actualTotalLabelsSet,containsInAnyOrder(expectedTotalLabelsMatcher))
|
||||
}
|
||||
private fun assertDatabaseState(expectedUnreadLocations: Iterable<UnreadLocationCounter> = unreadLocations,
|
||||
expectedUnreadLabels: Iterable<UnreadLabelCounter> = unreadLabels,
|
||||
expectedTotalLocations: Iterable<TotalLocationCounter> = totalLocations,
|
||||
expectedTotalLabels: Iterable<TotalLabelCounter> = totalLabels) {
|
||||
val expectedUnreadLocationsMatcher =
|
||||
expectedUnreadLocations.map { ReflectivePropertiesMatcher(it) }
|
||||
val expectedUnreadLabelsMatcher = expectedUnreadLabels.map { ReflectivePropertiesMatcher(it) }
|
||||
val expectedTotalLocationsMatcher =
|
||||
expectedTotalLocations.map { ReflectivePropertiesMatcher(it) }
|
||||
val expectedTotalLabelsMatcher = expectedTotalLabels.map { ReflectivePropertiesMatcher(it) }
|
||||
|
||||
private fun CountersDatabase.populate() {
|
||||
insertAllUnreadLocations(unreadLocations)
|
||||
insertAllUnreadLabels(unreadLabels)
|
||||
refreshTotalCounters(totalLocations,totalLabels)
|
||||
}
|
||||
val actualUnreadLocationsSet = database.findAllUnreadLocations().testValue
|
||||
val actualUnreadLabelsSet = database.findAllUnreadLabels().testValue
|
||||
val actualTotalLocationsSet = database.findAllTotalLocations().testValue
|
||||
val actualTotalLabelsSet = database.findAllTotalLabels().testValue
|
||||
Assert.assertThat(actualUnreadLocationsSet,
|
||||
containsInAnyOrder(expectedUnreadLocationsMatcher))
|
||||
Assert.assertThat(actualUnreadLabelsSet, containsInAnyOrder(expectedUnreadLabelsMatcher))
|
||||
Assert.assertThat(actualTotalLocationsSet, containsInAnyOrder(expectedTotalLocationsMatcher))
|
||||
Assert.assertThat(actualTotalLabelsSet, containsInAnyOrder(expectedTotalLabelsMatcher))
|
||||
}
|
||||
|
||||
@Before
|
||||
fun setUp() {
|
||||
database.populate()
|
||||
}
|
||||
private fun CountersDatabase.populate() {
|
||||
insertAllUnreadLocations(unreadLocations)
|
||||
insertAllUnreadLabels(unreadLabels)
|
||||
refreshTotalCounters(totalLocations, totalLabels)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun findAllUnreadLabels() {
|
||||
val expected=unreadLabels.matchers
|
||||
val actual=database.findAllUnreadLabels().testValue
|
||||
Assert.assertThat(actual,containsInAnyOrder(expected))
|
||||
assertDatabaseState()
|
||||
}
|
||||
@Before
|
||||
fun setUp() {
|
||||
database.populate()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun findUnreadLabelById() {
|
||||
val expected= ReflectivePropertiesMatcher(unreadLabels[1])
|
||||
val actual=database.findUnreadLabelById(unreadLabels[1].id)
|
||||
Assert.assertThat(actual,`is`(expected))
|
||||
assertDatabaseState()
|
||||
}
|
||||
@Test
|
||||
fun findAllUnreadLabels() {
|
||||
val expected = unreadLabels.matchers
|
||||
val actual = database.findAllUnreadLabels().testValue
|
||||
Assert.assertThat(actual, containsInAnyOrder(expected))
|
||||
assertDatabaseState()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun findUnreadLabelByIdShouldReturnNull() {
|
||||
val actual=database.findUnreadLabelById("e")
|
||||
Assert.assertNull(actual)
|
||||
assertDatabaseState()
|
||||
}
|
||||
@Test
|
||||
fun findUnreadLabelById() {
|
||||
val expected = ReflectivePropertiesMatcher(unreadLabels[1])
|
||||
val actual = database.findUnreadLabelById(unreadLabels[1].id)
|
||||
Assert.assertThat(actual, `is`(expected))
|
||||
assertDatabaseState()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun clearUnreadLabelsTable() {
|
||||
database.clearUnreadLabelsTable()
|
||||
assertDatabaseState(expectedUnreadLabels=emptyList())
|
||||
}
|
||||
@Test
|
||||
fun findUnreadLabelByIdShouldReturnNull() {
|
||||
val actual = database.findUnreadLabelById("e")
|
||||
Assert.assertNull(actual)
|
||||
assertDatabaseState()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun insertUnreadLabel() {
|
||||
val inserted=UnreadLabelCounter("e",8)
|
||||
val expected=unreadLabels+inserted
|
||||
database.insertUnreadLabel(inserted)
|
||||
assertDatabaseState(expectedUnreadLabels=expected)
|
||||
}
|
||||
@Test
|
||||
fun clearUnreadLabelsTable() {
|
||||
database.clearUnreadLabelsTable()
|
||||
assertDatabaseState(expectedUnreadLabels = emptyList())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun insertAllUnreadLabels() {
|
||||
val inserted=listOf(UnreadLabelCounter("e",8),UnreadLabelCounter("f",7))
|
||||
val expected=unreadLabels+inserted
|
||||
database.insertAllUnreadLabels(inserted)
|
||||
assertDatabaseState(expectedUnreadLabels=expected)
|
||||
}
|
||||
@Test
|
||||
fun insertUnreadLabel() {
|
||||
val inserted = UnreadLabelCounter("e", 8)
|
||||
val expected = unreadLabels + inserted
|
||||
database.insertUnreadLabel(inserted)
|
||||
assertDatabaseState(expectedUnreadLabels = expected)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun unreadLabelsReplace() {
|
||||
val replaced=UnreadLabelCounter("a",100)
|
||||
val expected=unreadLabels.toMutableList()
|
||||
expected[0]=replaced
|
||||
database.insertUnreadLabel(replaced)
|
||||
assertDatabaseState(expectedUnreadLabels=expected)
|
||||
}
|
||||
@Test
|
||||
fun insertAllUnreadLabels() {
|
||||
val inserted = listOf(UnreadLabelCounter("e", 8), UnreadLabelCounter("f", 7))
|
||||
val expected = unreadLabels + inserted
|
||||
database.insertAllUnreadLabels(inserted)
|
||||
assertDatabaseState(expectedUnreadLabels = expected)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun unreadLabelsReplaceAll() {
|
||||
val replaced=listOf(UnreadLabelCounter("a",100),UnreadLabelCounter("b",101))
|
||||
val expected=unreadLabels.toMutableList()
|
||||
expected[0]=replaced[0]
|
||||
expected[1]=replaced[1]
|
||||
database.insertAllUnreadLabels(replaced)
|
||||
assertDatabaseState(expectedUnreadLabels=expected)
|
||||
}
|
||||
@Test
|
||||
fun unreadLabelsReplace() {
|
||||
val replaced = UnreadLabelCounter("a", 100)
|
||||
val expected = unreadLabels.toMutableList()
|
||||
expected[0] = replaced
|
||||
database.insertUnreadLabel(replaced)
|
||||
assertDatabaseState(expectedUnreadLabels = expected)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun findUnreadLocationById() {
|
||||
unreadLabels.forEach {
|
||||
val expected=it
|
||||
val actual=database.findUnreadLabelById(it.id)
|
||||
Assert.assertThat(actual,`is`(ReflectivePropertiesMatcher(expected)))
|
||||
}
|
||||
assertDatabaseState()
|
||||
}
|
||||
@Test
|
||||
fun unreadLabelsReplaceAll() {
|
||||
val replaced = listOf(UnreadLabelCounter("a", 100), UnreadLabelCounter("b", 101))
|
||||
val expected = unreadLabels.toMutableList()
|
||||
expected[0] = replaced[0]
|
||||
expected[1] = replaced[1]
|
||||
database.insertAllUnreadLabels(replaced)
|
||||
assertDatabaseState(expectedUnreadLabels = expected)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun findUnreadLocationByIdShouldReturnNull() {
|
||||
val actual=database.findUnreadLocationById(5)
|
||||
Assert.assertNull(actual)
|
||||
assertDatabaseState()
|
||||
}
|
||||
@Test
|
||||
fun findUnreadLocationById() {
|
||||
unreadLabels.forEach {
|
||||
val expected = it
|
||||
val actual = database.findUnreadLabelById(it.id)
|
||||
Assert.assertThat(actual!!, `is`(ReflectivePropertiesMatcher(expected)))
|
||||
}
|
||||
assertDatabaseState()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun findAllUnreadLocations() {
|
||||
val expected=unreadLocations.map {ReflectivePropertiesMatcher(it)}
|
||||
val actual=database.findAllUnreadLocations().testValue
|
||||
Assert.assertThat(actual,containsInAnyOrder(expected))
|
||||
assertDatabaseState()
|
||||
}
|
||||
@Test
|
||||
fun findUnreadLocationByIdShouldReturnNull() {
|
||||
val actual = database.findUnreadLocationById(5)
|
||||
Assert.assertNull(actual)
|
||||
assertDatabaseState()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun clearUnreadLocationsTable() {
|
||||
database.clearUnreadLocationsTable()
|
||||
assertDatabaseState(expectedUnreadLocations=emptyList())
|
||||
}
|
||||
@Test
|
||||
fun findAllUnreadLocations() {
|
||||
val expected = unreadLocations.map { ReflectivePropertiesMatcher(it) }
|
||||
val actual = database.findAllUnreadLocations().testValue
|
||||
Assert.assertThat(actual, containsInAnyOrder(expected))
|
||||
assertDatabaseState()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun insertUnreadLocation() {
|
||||
val inserted=UnreadLocationCounter(5,8)
|
||||
val expected=unreadLocations+inserted
|
||||
database.insertUnreadLocation(inserted)
|
||||
assertDatabaseState(expectedUnreadLocations=expected)
|
||||
}
|
||||
@Test
|
||||
fun clearUnreadLocationsTable() {
|
||||
database.clearUnreadLocationsTable()
|
||||
assertDatabaseState(expectedUnreadLocations = emptyList())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun insertAllUnreadLocations() {
|
||||
val inserted=listOf(UnreadLocationCounter(5,8),UnreadLocationCounter(6,7))
|
||||
val expected=unreadLocations+inserted
|
||||
database.insertAllUnreadLocations(inserted)
|
||||
assertDatabaseState(expectedUnreadLocations=expected)
|
||||
}
|
||||
@Test
|
||||
fun insertUnreadLocation() {
|
||||
val inserted = UnreadLocationCounter(5, 8)
|
||||
val expected = unreadLocations + inserted
|
||||
database.insertUnreadLocation(inserted)
|
||||
assertDatabaseState(expectedUnreadLocations = expected)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun unreadLocationsReplace() {
|
||||
val replaced=UnreadLocationCounter(1,100)
|
||||
val expected=unreadLocations.toMutableList()
|
||||
expected[0]=replaced
|
||||
database.insertUnreadLocation(replaced)
|
||||
assertDatabaseState(expectedUnreadLocations=expected)
|
||||
}
|
||||
@Test
|
||||
fun insertAllUnreadLocations() {
|
||||
val inserted = listOf(UnreadLocationCounter(5, 8), UnreadLocationCounter(6, 7))
|
||||
val expected = unreadLocations + inserted
|
||||
database.insertAllUnreadLocations(inserted)
|
||||
assertDatabaseState(expectedUnreadLocations = expected)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun unreadLocationsReplaceAll() {
|
||||
val replaced=listOf(UnreadLocationCounter(1,100),UnreadLocationCounter(2,101))
|
||||
val expected=unreadLocations.toMutableList()
|
||||
expected[0]=replaced[0]
|
||||
expected[1]=replaced[1]
|
||||
database.insertAllUnreadLocations(replaced)
|
||||
assertDatabaseState(expectedUnreadLocations=expected)
|
||||
}
|
||||
@Test
|
||||
fun unreadLocationsReplace() {
|
||||
val replaced = UnreadLocationCounter(1, 100)
|
||||
val expected = unreadLocations.toMutableList()
|
||||
expected[0] = replaced
|
||||
database.insertUnreadLocation(replaced)
|
||||
assertDatabaseState(expectedUnreadLocations = expected)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun updateUnreadCounters() {
|
||||
val insertedLabels=listOf(UnreadLabelCounter("e",8),UnreadLabelCounter("f",7))
|
||||
val insertedLocations=listOf(UnreadLocationCounter(5,8),UnreadLocationCounter(6,7))
|
||||
database.updateUnreadCounters(insertedLocations,insertedLabels)
|
||||
assertDatabaseState(expectedUnreadLocations=insertedLocations,
|
||||
expectedUnreadLabels=insertedLabels)
|
||||
}
|
||||
@Test
|
||||
fun unreadLocationsReplaceAll() {
|
||||
val replaced = listOf(UnreadLocationCounter(1, 100), UnreadLocationCounter(2, 101))
|
||||
val expected = unreadLocations.toMutableList()
|
||||
expected[0] = replaced[0]
|
||||
expected[1] = replaced[1]
|
||||
database.insertAllUnreadLocations(replaced)
|
||||
assertDatabaseState(expectedUnreadLocations = expected)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun findAllTotalLabels() {
|
||||
val expected=totalLabels.matchers
|
||||
val actual=database.findAllTotalLabels().testValue
|
||||
Assert.assertThat(actual,containsInAnyOrder(expected))
|
||||
assertDatabaseState()
|
||||
}
|
||||
@Test
|
||||
fun updateUnreadCounters() {
|
||||
val insertedLabels = listOf(UnreadLabelCounter("e", 8), UnreadLabelCounter("f", 7))
|
||||
val insertedLocations = listOf(UnreadLocationCounter(5, 8), UnreadLocationCounter(6, 7))
|
||||
database.updateUnreadCounters(insertedLocations, insertedLabels)
|
||||
assertDatabaseState(expectedUnreadLocations = insertedLocations,
|
||||
expectedUnreadLabels = insertedLabels)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun findTotalLabelById() {
|
||||
val expected=totalLabels[1]
|
||||
val actual=database.findTotalLabelById(totalLabels[1].id)
|
||||
Assert.assertThat(actual,`is`(ReflectivePropertiesMatcher(expected)))
|
||||
assertDatabaseState()
|
||||
}
|
||||
@Test
|
||||
fun findAllTotalLabels() {
|
||||
val expected = totalLabels.matchers
|
||||
val actual = database.findAllTotalLabels().testValue
|
||||
Assert.assertThat(actual, containsInAnyOrder(expected))
|
||||
assertDatabaseState()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun clearTotalLabelsTable() {
|
||||
database.clearTotalLabelsTable()
|
||||
assertDatabaseState(expectedTotalLabels=emptyList())
|
||||
}
|
||||
@Test
|
||||
fun findTotalLabelById() {
|
||||
val expected = totalLabels[1]
|
||||
val actual = database.findTotalLabelById(totalLabels[1].id)
|
||||
Assert.assertThat(actual!!, `is`(ReflectivePropertiesMatcher(expected)))
|
||||
assertDatabaseState()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun findTotalLocationById() {
|
||||
totalLocations.forEach {
|
||||
val expected=it
|
||||
val actual=database.findTotalLocationById(it.id)
|
||||
Assert.assertThat(actual,`is`(ReflectivePropertiesMatcher(expected)))
|
||||
}
|
||||
assertDatabaseState()
|
||||
}
|
||||
@Test
|
||||
fun clearTotalLabelsTable() {
|
||||
database.clearTotalLabelsTable()
|
||||
assertDatabaseState(expectedTotalLabels = emptyList())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun findTotalLocationByIdShouldReturnNull() {
|
||||
val actual=database.findTotalLocationById(5)
|
||||
Assert.assertNull(actual)
|
||||
assertDatabaseState()
|
||||
}
|
||||
@Test
|
||||
fun findTotalLocationById() {
|
||||
totalLocations.forEach {
|
||||
val expected = it
|
||||
val actual = database.findTotalLocationById(it.id)
|
||||
Assert.assertThat(actual!!, `is`(ReflectivePropertiesMatcher(expected)))
|
||||
}
|
||||
assertDatabaseState()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun findAllTotalLocations() {
|
||||
val expected=totalLocations.matchers
|
||||
val actual=database.findAllTotalLocations().testValue!!
|
||||
Assert.assertThat(actual,containsInAnyOrder(expected))
|
||||
assertDatabaseState()
|
||||
}
|
||||
@Test
|
||||
fun findTotalLocationByIdShouldReturnNull() {
|
||||
val actual = database.findTotalLocationById(5)
|
||||
Assert.assertNull(actual)
|
||||
assertDatabaseState()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun clearTotalLocationsTable() {
|
||||
database.clearTotalLocationsTable()
|
||||
assertDatabaseState(expectedTotalLocations=emptyList())
|
||||
}
|
||||
@Test
|
||||
fun findAllTotalLocations() {
|
||||
val expected = totalLocations.matchers
|
||||
val actual = database.findAllTotalLocations().testValue!!
|
||||
Assert.assertThat(actual, containsInAnyOrder(expected))
|
||||
assertDatabaseState()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun refreshTotalCounters() {
|
||||
val insertedLabels=listOf(TotalLabelCounter("e",8),TotalLabelCounter("f",7))
|
||||
val insertedLocations=listOf(TotalLocationCounter(5,8),TotalLocationCounter(6,7))
|
||||
database.refreshTotalCounters(insertedLocations,insertedLabels)
|
||||
assertDatabaseState(expectedTotalLocations=insertedLocations,
|
||||
expectedTotalLabels=insertedLabels)
|
||||
}
|
||||
@Test
|
||||
fun clearTotalLocationsTable() {
|
||||
database.clearTotalLocationsTable()
|
||||
assertDatabaseState(expectedTotalLocations = emptyList())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun refreshTotalCounters() {
|
||||
val insertedLabels = listOf(TotalLabelCounter("e", 8), TotalLabelCounter("f", 7))
|
||||
val insertedLocations = listOf(TotalLocationCounter(5, 8), TotalLocationCounter(6, 7))
|
||||
database.refreshTotalCounters(insertedLocations, insertedLabels)
|
||||
assertDatabaseState(expectedTotalLocations = insertedLocations,
|
||||
expectedTotalLabels = insertedLabels)
|
||||
}
|
||||
}
|
|
@ -19,7 +19,8 @@
|
|||
package ch.protonmail.android.api.models.room.notifications
|
||||
|
||||
import androidx.room.Room
|
||||
import androidx.test.InstrumentationRegistry
|
||||
import androidx.test.core.app.ApplicationProvider
|
||||
import ch.protonmail.android.core.ProtonMailApplication
|
||||
import ch.protonmail.android.testAndroidInstrumented.ReflectivePropertiesMatcher
|
||||
import ch.protonmail.android.testAndroidInstrumented.matchers
|
||||
import org.hamcrest.Matchers.`is`
|
||||
|
@ -31,79 +32,79 @@ import org.junit.Test
|
|||
/**
|
||||
* Created by Kamil Rajtar on 05.09.18. */
|
||||
internal class NotificationsDatabaseTest {
|
||||
private val context=InstrumentationRegistry.getTargetContext()
|
||||
private val databaseFactory=Room.inMemoryDatabaseBuilder(context,
|
||||
NotificationsDatabaseFactory::class.java).build()
|
||||
private val database=databaseFactory.getDatabase()
|
||||
private val context = ApplicationProvider.getApplicationContext<ProtonMailApplication>()
|
||||
private val databaseFactory = Room.inMemoryDatabaseBuilder(context,
|
||||
NotificationsDatabaseFactory::class.java).build()
|
||||
private val database = databaseFactory.getDatabase()
|
||||
|
||||
private val notifications=listOf(
|
||||
Notification("a","aa","aaa").apply {dbId=3},
|
||||
Notification("b","bb","bbb").apply {dbId=2},
|
||||
Notification("c","cc","ccc").apply {dbId=1},
|
||||
Notification("d","dd","ddd").apply {dbId=8},
|
||||
Notification("e","ee","eee").apply {dbId=7}
|
||||
)
|
||||
private val notifications = listOf(
|
||||
Notification("a", "aa", "aaa").apply { dbId = 3 },
|
||||
Notification("b", "bb", "bbb").apply { dbId = 2 },
|
||||
Notification("c", "cc", "ccc").apply { dbId = 1 },
|
||||
Notification("d", "dd", "ddd").apply { dbId = 8 },
|
||||
Notification("e", "ee", "eee").apply { dbId = 7 }
|
||||
)
|
||||
|
||||
private fun NotificationsDatabase.populate() {
|
||||
notifications.forEach(this::insertNotification)
|
||||
}
|
||||
private fun NotificationsDatabase.populate() {
|
||||
notifications.forEach(this::insertNotification)
|
||||
}
|
||||
|
||||
@Before
|
||||
fun setUp(){
|
||||
database.populate()
|
||||
}
|
||||
@Before
|
||||
fun setUp() {
|
||||
database.populate()
|
||||
}
|
||||
|
||||
private fun assertDatabaseState(expectedNotifications:List<Notification> =notifications){
|
||||
val expected=expectedNotifications.matchers
|
||||
val actual=database.findAllNotifications()
|
||||
Assert.assertThat(actual,containsInAnyOrder(expected))
|
||||
}
|
||||
private fun assertDatabaseState(expectedNotifications: List<Notification> = notifications) {
|
||||
val expected = expectedNotifications.matchers
|
||||
val actual = database.findAllNotifications()
|
||||
Assert.assertThat(actual, containsInAnyOrder(expected))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun findByMessageId() {
|
||||
notifications.forEach{
|
||||
val expected=it
|
||||
val actual=database.findByMessageId(it.messageId)
|
||||
Assert.assertThat(actual,`is`(ReflectivePropertiesMatcher(expected)))
|
||||
}
|
||||
assertDatabaseState()
|
||||
}
|
||||
@Test
|
||||
fun findByMessageId() {
|
||||
notifications.forEach {
|
||||
val expected = it
|
||||
val actual = database.findByMessageId(it.messageId)
|
||||
Assert.assertThat(actual!!, `is`(ReflectivePropertiesMatcher(expected)))
|
||||
}
|
||||
assertDatabaseState()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun findByMessageIdShouldReturnNull() {
|
||||
val actual=database.findByMessageId("asfsagsg")
|
||||
Assert.assertNull(actual)
|
||||
assertDatabaseState()
|
||||
}
|
||||
@Test
|
||||
fun findByMessageIdShouldReturnNull() {
|
||||
val actual = database.findByMessageId("asfsagsg")
|
||||
Assert.assertNull(actual)
|
||||
assertDatabaseState()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun deleteByMessageId() {
|
||||
val deletedId=notifications[0].messageId
|
||||
val expected=notifications.filterNot {it.messageId==deletedId}
|
||||
database.deleteByMessageId(deletedId)
|
||||
assertDatabaseState(expectedNotifications = expected)
|
||||
}
|
||||
@Test
|
||||
fun deleteByMessageId() {
|
||||
val deletedId = notifications[0].messageId
|
||||
val expected = notifications.filterNot { it.messageId == deletedId }
|
||||
database.deleteByMessageId(deletedId)
|
||||
assertDatabaseState(expectedNotifications = expected)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun insertNotification() {
|
||||
val inserted=Notification("j","jj","jjj").apply {}
|
||||
database.insertNotification(inserted)
|
||||
inserted.dbId=database.findByMessageId("j")!!.dbId
|
||||
assertDatabaseState(expectedNotifications=notifications+inserted)
|
||||
}
|
||||
@Test
|
||||
fun insertNotification() {
|
||||
val inserted = Notification("j", "jj", "jjj").apply {}
|
||||
database.insertNotification(inserted)
|
||||
inserted.dbId = database.findByMessageId("j")!!.dbId
|
||||
assertDatabaseState(expectedNotifications = notifications + inserted)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun clearNotificationCache() {
|
||||
database.clearNotificationCache()
|
||||
assertDatabaseState(expectedNotifications=emptyList())
|
||||
}
|
||||
@Test
|
||||
fun clearNotificationCache() {
|
||||
database.clearNotificationCache()
|
||||
assertDatabaseState(expectedNotifications = emptyList())
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
fun deleteNotifications() {
|
||||
val deleted=listOf(notifications[2],notifications[1])
|
||||
val expected=notifications-deleted
|
||||
database.deleteNotifications(deleted)
|
||||
assertDatabaseState(expectedNotifications=expected)
|
||||
}
|
||||
@Test
|
||||
fun deleteNotifications() {
|
||||
val deleted = listOf(notifications[2], notifications[1])
|
||||
val expected = notifications - deleted
|
||||
database.deleteNotifications(deleted)
|
||||
assertDatabaseState(expectedNotifications = expected)
|
||||
}
|
||||
}
|
|
@ -20,11 +20,11 @@ package ch.protonmail.android.api.models.room.pendingActions
|
|||
|
||||
import androidx.arch.core.executor.testing.InstantTaskExecutorRule
|
||||
import androidx.room.Room
|
||||
import androidx.test.InstrumentationRegistry
|
||||
import androidx.test.core.app.ApplicationProvider
|
||||
import ch.protonmail.android.api.models.room.testValue
|
||||
import ch.protonmail.android.core.ProtonMailApplication
|
||||
import ch.protonmail.android.testAndroidInstrumented.ReflectivePropertiesMatcher
|
||||
import ch.protonmail.android.testAndroidInstrumented.matchers
|
||||
import org.hamcrest.Matchers
|
||||
import org.hamcrest.Matchers.`is`
|
||||
import org.hamcrest.Matchers.containsInAnyOrder
|
||||
import org.junit.Assert
|
||||
|
@ -36,138 +36,139 @@ import org.junit.Test
|
|||
* Created by Kamil Rajtar on 06.09.18. */
|
||||
internal class PendingActionsDatabaseTest {
|
||||
|
||||
private val context = InstrumentationRegistry.getTargetContext()
|
||||
private var databaseFactory = Room.inMemoryDatabaseBuilder(context, PendingActionsDatabaseFactory::class.java).build()
|
||||
private var database = databaseFactory.getDatabase()
|
||||
@get:Rule
|
||||
var instantTaskExecutorRule = InstantTaskExecutorRule()
|
||||
private val context = ApplicationProvider.getApplicationContext<ProtonMailApplication>()
|
||||
private var databaseFactory = Room.inMemoryDatabaseBuilder(context, PendingActionsDatabaseFactory::class.java).build()
|
||||
private var database = databaseFactory.getDatabase()
|
||||
|
||||
private val pendingSends=listOf(
|
||||
PendingSend("a","aa","aaa",false,5),
|
||||
PendingSend("b","bb","bbb",true,7),
|
||||
PendingSend("c","cc","ccc",false,3),
|
||||
PendingSend("d","dd","ddd",true,2),
|
||||
PendingSend("e","ee","eee",false,1),
|
||||
PendingSend("f","ff","fff",true,9)
|
||||
)
|
||||
private val pendingUploads=listOf(
|
||||
PendingUpload("a"),
|
||||
PendingUpload("b"),
|
||||
PendingUpload("c"),
|
||||
PendingUpload("d"),
|
||||
PendingUpload("e")
|
||||
)
|
||||
@get:Rule
|
||||
var instantTaskExecutorRule = InstantTaskExecutorRule()
|
||||
|
||||
private fun PendingActionsDatabase.populate() {
|
||||
pendingSends.forEach(this::insertPendingForSend)
|
||||
pendingUploads.forEach(this::insertPendingForUpload)
|
||||
}
|
||||
private val pendingSends = listOf(
|
||||
PendingSend("a", "aa", "aaa", false, 5),
|
||||
PendingSend("b", "bb", "bbb", true, 7),
|
||||
PendingSend("c", "cc", "ccc", false, 3),
|
||||
PendingSend("d", "dd", "ddd", true, 2),
|
||||
PendingSend("e", "ee", "eee", false, 1),
|
||||
PendingSend("f", "ff", "fff", true, 9)
|
||||
)
|
||||
private val pendingUploads = listOf(
|
||||
PendingUpload("a"),
|
||||
PendingUpload("b"),
|
||||
PendingUpload("c"),
|
||||
PendingUpload("d"),
|
||||
PendingUpload("e")
|
||||
)
|
||||
|
||||
@Before
|
||||
fun setUp() {
|
||||
database.populate()
|
||||
}
|
||||
private fun PendingActionsDatabase.populate() {
|
||||
pendingSends.forEach(this::insertPendingForSend)
|
||||
pendingUploads.forEach(this::insertPendingForUpload)
|
||||
}
|
||||
|
||||
private fun assertDatabaseState(expectedSends:Iterable<PendingSend> =pendingSends,
|
||||
expectedUploads:Iterable<PendingUpload> =pendingUploads) {
|
||||
val expectedSendsMatcher=expectedSends.map { ReflectivePropertiesMatcher(it) }
|
||||
val expectedUploadsMatcher=expectedUploads.map {ReflectivePropertiesMatcher(it)}
|
||||
@Before
|
||||
fun setUp() {
|
||||
database.populate()
|
||||
}
|
||||
|
||||
val actualSendsSet=database.findAllPendingSendsAsync().testValue
|
||||
val actualUploadsSet=database.findAllPendingUploadsAsync().testValue
|
||||
Assert.assertThat(actualSendsSet,containsInAnyOrder(expectedSendsMatcher))
|
||||
Assert.assertThat(actualUploadsSet,containsInAnyOrder(expectedUploadsMatcher))
|
||||
}
|
||||
private fun assertDatabaseState(expectedSends: Iterable<PendingSend> = pendingSends,
|
||||
expectedUploads: Iterable<PendingUpload> = pendingUploads) {
|
||||
val expectedSendsMatcher = expectedSends.map { ReflectivePropertiesMatcher(it) }
|
||||
val expectedUploadsMatcher = expectedUploads.map { ReflectivePropertiesMatcher(it) }
|
||||
|
||||
@Test
|
||||
fun insertPendingForSend() {
|
||||
val inserted=PendingSend("z","zz","zzz",true,101)
|
||||
val expected=pendingSends+inserted
|
||||
database.insertPendingForSend(inserted)
|
||||
assertDatabaseState(expectedSends = expected)
|
||||
}
|
||||
val actualSendsSet = database.findAllPendingSendsAsync().testValue
|
||||
val actualUploadsSet = database.findAllPendingUploadsAsync().testValue
|
||||
Assert.assertThat(actualSendsSet, containsInAnyOrder(expectedSendsMatcher))
|
||||
Assert.assertThat(actualUploadsSet, containsInAnyOrder(expectedUploadsMatcher))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun findPendingSendByMessageId() {
|
||||
val expected=pendingSends[3]
|
||||
val actual=database.findPendingSendByMessageId(expected.messageId!!)
|
||||
Assert.assertThat(actual,`is`(ReflectivePropertiesMatcher(expected)))
|
||||
assertDatabaseState()
|
||||
}
|
||||
@Test
|
||||
fun insertPendingForSend() {
|
||||
val inserted = PendingSend("z", "zz", "zzz", true, 101)
|
||||
val expected = pendingSends + inserted
|
||||
database.insertPendingForSend(inserted)
|
||||
assertDatabaseState(expectedSends = expected)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun deletePendingSendByMessageId() {
|
||||
val deleted=pendingSends[3]
|
||||
val expected=pendingSends.filterNot {it.messageId==deleted.messageId}
|
||||
database.deletePendingSendByMessageId(deleted.messageId!!)
|
||||
assertDatabaseState(expectedSends =expected)
|
||||
}
|
||||
@Test
|
||||
fun findPendingSendByMessageId() {
|
||||
val expected = pendingSends[3]
|
||||
val actual = database.findPendingSendByMessageId(expected.messageId!!)
|
||||
Assert.assertThat(actual!!, `is`(ReflectivePropertiesMatcher(expected)))
|
||||
assertDatabaseState()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun findPendingSendByOfflineMessageId() {
|
||||
val expected=pendingSends[3]
|
||||
val actual=database.findPendingSendByOfflineMessageId(expected.offlineMessageId!!)
|
||||
Assert.assertThat(actual,Matchers.`is`(ReflectivePropertiesMatcher(expected)))
|
||||
assertDatabaseState()
|
||||
}
|
||||
@Test
|
||||
fun deletePendingSendByMessageId() {
|
||||
val deleted = pendingSends[3]
|
||||
val expected = pendingSends.filterNot { it.messageId == deleted.messageId }
|
||||
database.deletePendingSendByMessageId(deleted.messageId!!)
|
||||
assertDatabaseState(expectedSends = expected)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun findPendingSendByOfflineMessageIdAsync() {
|
||||
val expected=pendingSends[3]
|
||||
val actual=database.findPendingSendByOfflineMessageIdAsync(expected.offlineMessageId!!).testValue
|
||||
Assert.assertThat(actual,Matchers.`is`(ReflectivePropertiesMatcher(expected)))
|
||||
assertDatabaseState()
|
||||
}
|
||||
@Test
|
||||
fun findPendingSendByOfflineMessageId() {
|
||||
val expected = pendingSends[3]
|
||||
val actual = database.findPendingSendByOfflineMessageId(expected.offlineMessageId!!)
|
||||
Assert.assertThat(actual!!, `is`(ReflectivePropertiesMatcher(expected)))
|
||||
assertDatabaseState()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun findPendingSendByDbId() {
|
||||
val expected=pendingSends[3]
|
||||
val actual=database.findPendingSendByDbId(expected.localDatabaseId)
|
||||
Assert.assertThat(actual,Matchers.`is`(ReflectivePropertiesMatcher(expected)))
|
||||
assertDatabaseState()
|
||||
}
|
||||
@Test
|
||||
fun findPendingSendByOfflineMessageIdAsync() {
|
||||
val expected = pendingSends[3]
|
||||
val actual = database.findPendingSendByOfflineMessageIdAsync(expected.offlineMessageId!!).testValue
|
||||
Assert.assertThat(actual!!, `is`(ReflectivePropertiesMatcher(expected)))
|
||||
assertDatabaseState()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun clearPendingSendCache() {
|
||||
database.clearPendingSendCache()
|
||||
assertDatabaseState(expectedSends = emptyList())
|
||||
}
|
||||
@Test
|
||||
fun findPendingSendByDbId() {
|
||||
val expected = pendingSends[3]
|
||||
val actual = database.findPendingSendByDbId(expected.localDatabaseId)
|
||||
Assert.assertThat(actual!!, `is`(ReflectivePropertiesMatcher(expected)))
|
||||
assertDatabaseState()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun insertPendingForUpload() {
|
||||
val inserted=PendingUpload("z")
|
||||
val expected=pendingUploads+inserted
|
||||
database.insertPendingForUpload(inserted)
|
||||
assertDatabaseState(expectedUploads =expected)
|
||||
}
|
||||
@Test
|
||||
fun clearPendingSendCache() {
|
||||
database.clearPendingSendCache()
|
||||
assertDatabaseState(expectedSends = emptyList())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun findAllPendingUploadsAsync() {
|
||||
val expected=pendingUploads.matchers
|
||||
val actual=database.findAllPendingUploadsAsync().testValue!!
|
||||
Assert.assertThat(actual,containsInAnyOrder(expected))
|
||||
assertDatabaseState()
|
||||
}
|
||||
@Test
|
||||
fun insertPendingForUpload() {
|
||||
val inserted = PendingUpload("z")
|
||||
val expected = pendingUploads + inserted
|
||||
database.insertPendingForUpload(inserted)
|
||||
assertDatabaseState(expectedUploads = expected)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun findPendingUploadByMessageId() {
|
||||
val expected=pendingUploads[2]
|
||||
val actual=database.findPendingUploadByMessageId(expected.messageId)
|
||||
Assert.assertEquals(expected,actual)
|
||||
assertDatabaseState()
|
||||
}
|
||||
@Test
|
||||
fun findAllPendingUploadsAsync() {
|
||||
val expected = pendingUploads.matchers
|
||||
val actual = database.findAllPendingUploadsAsync().testValue!!
|
||||
Assert.assertThat(actual, containsInAnyOrder(expected))
|
||||
assertDatabaseState()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun deletePendingUploadByMessageId() {
|
||||
val deletedId=pendingUploads[2].messageId
|
||||
val expected=pendingUploads.filterNot {it.messageId==deletedId}
|
||||
database.deletePendingUploadByMessageId(deletedId)
|
||||
assertDatabaseState(expectedUploads = expected)
|
||||
}
|
||||
@Test
|
||||
fun findPendingUploadByMessageId() {
|
||||
val expected = pendingUploads[2]
|
||||
val actual = database.findPendingUploadByMessageId(expected.messageId)
|
||||
Assert.assertEquals(expected, actual)
|
||||
assertDatabaseState()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun clearPendingUploadCache() {
|
||||
database.clearPendingUploadCache()
|
||||
assertDatabaseState(expectedUploads = emptyList())
|
||||
}
|
||||
@Test
|
||||
fun deletePendingUploadByMessageId() {
|
||||
val deletedId = pendingUploads[2].messageId
|
||||
val expected = pendingUploads.filterNot { it.messageId == deletedId }
|
||||
database.deletePendingUploadByMessageId(deletedId)
|
||||
assertDatabaseState(expectedUploads = expected)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun clearPendingUploadCache() {
|
||||
database.clearPendingUploadCache()
|
||||
assertDatabaseState(expectedUploads = emptyList())
|
||||
}
|
||||
}
|
|
@ -19,7 +19,6 @@ along with ProtonMail. If not, see https://www.gnu.org/licenses/.
|
|||
-->
|
||||
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
package="ch.protonmail.android">
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
|
@ -50,7 +49,6 @@ along with ProtonMail. If not, see https://www.gnu.org/licenses/.
|
|||
|
||||
<application
|
||||
android:name=".core.ProtonMailApplication"
|
||||
tools:replace="android:allowBackup"
|
||||
android:allowBackup="false"
|
||||
android:supportsRtl="true"
|
||||
android:usesCleartextTraffic="true"
|
||||
|
|
|
@ -32,7 +32,6 @@ import androidx.drawerlayout.widget.DrawerLayout
|
|||
import androidx.lifecycle.Observer
|
||||
import androidx.lifecycle.ViewModelProviders
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import ch.protonmail.android.BuildConfig
|
||||
import ch.protonmail.android.R
|
||||
import ch.protonmail.android.activities.dialogs.QuickSnoozeDialogFragment
|
||||
import ch.protonmail.android.activities.mailbox.MailboxActivity
|
||||
|
@ -77,7 +76,6 @@ import ch.protonmail.android.utils.resettableManager
|
|||
import ch.protonmail.android.utils.ui.dialogs.DialogUtils
|
||||
import ch.protonmail.android.views.DrawerHeaderView
|
||||
import kotlinx.android.synthetic.main.drawer_header.*
|
||||
import timber.log.Timber
|
||||
import java.util.*
|
||||
import javax.inject.Inject
|
||||
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
/*
|
||||
* Copyright (c) 2020 Proton Technologies AG
|
||||
*
|
||||
*
|
||||
* This file is part of ProtonMail.
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with ProtonMail. If not, see https://www.gnu.org/licenses/.
|
||||
*/
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
/*
|
||||
* Copyright (c) 2020 Proton Technologies AG
|
||||
*
|
||||
*
|
||||
* This file is part of ProtonMail.
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with ProtonMail. If not, see https://www.gnu.org/licenses/.
|
||||
*/
|
||||
|
|
|
@ -23,6 +23,7 @@ import android.text.TextUtils
|
|||
|
||||
import ch.protonmail.android.R
|
||||
|
||||
|
||||
object Constants {
|
||||
|
||||
// region Urls
|
||||
|
|
|
@ -20,6 +20,7 @@ package ch.protonmail.android.core;
|
|||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Application;
|
||||
import android.app.NotificationManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
@ -38,7 +39,6 @@ import android.widget.TextView;
|
|||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.multidex.MultiDexApplication;
|
||||
|
||||
import com.birbit.android.jobqueue.JobManager;
|
||||
import com.datatheorem.android.trustkit.TrustKit;
|
||||
|
@ -129,7 +129,7 @@ import static ch.protonmail.android.core.UserManagerKt.PREF_SHOW_STORAGE_LIMIT_R
|
|||
import static ch.protonmail.android.core.UserManagerKt.PREF_SHOW_STORAGE_LIMIT_WARNING;
|
||||
|
||||
@Singleton
|
||||
public class ProtonMailApplication extends MultiDexApplication implements HasActivityInjector {
|
||||
public class ProtonMailApplication extends Application implements HasActivityInjector {
|
||||
|
||||
private static ProtonMailApplication sInstance;
|
||||
|
||||
|
|
|
@ -18,13 +18,15 @@
|
|||
*/
|
||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||
|
||||
initVersions()
|
||||
|
||||
buildscript {
|
||||
repositories(repos)
|
||||
dependencies(classpathDependencies)
|
||||
}
|
||||
|
||||
plugins {
|
||||
apply(Plugin.sonarQube, withVersion = true)
|
||||
`sonarQube`
|
||||
}
|
||||
|
||||
allprojects {
|
||||
|
|
|
@ -26,12 +26,11 @@ repositories {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
val android = "3.5.0" // Updated: Aug 08, 2019
|
||||
val dokka = "0.9.18" // Updated: Mar 19, 2019
|
||||
val sentry = "1.7.22" // Updated:
|
||||
val android = "3.5.0" // Updated: Aug 08, 2019
|
||||
val easyGradle = "1.2.3-beta-4" // Updated: Mar 01, 2020
|
||||
val sentry = "1.7.22" // Updated:
|
||||
|
||||
implementation("com.android.tools.build:gradle:$android")
|
||||
implementation("org.jetbrains.dokka:dokka-gradle-plugin:$dokka")
|
||||
implementation("org.jetbrains.dokka:dokka-android-gradle-plugin:$dokka")
|
||||
implementation("studio.forface.easygradle:dsl-android:$easyGradle")
|
||||
implementation("io.sentry:sentry-android-gradle-plugin:$sentry")
|
||||
}
|
||||
|
|
|
@ -17,55 +17,40 @@
|
|||
* along with ProtonMail. If not, see https://www.gnu.org/licenses/.
|
||||
*/
|
||||
import com.android.build.gradle.TestedExtension
|
||||
import com.android.build.gradle.internal.dsl.DefaultConfig
|
||||
import org.gradle.api.JavaVersion
|
||||
import org.gradle.api.plugins.ExtensionAware
|
||||
import org.gradle.kotlin.dsl.configure
|
||||
import studio.forface.easygradle.dsl.android.*
|
||||
|
||||
/**
|
||||
* Apply the default Android configuration for `app` module
|
||||
*
|
||||
* @param extraConfig [ExtraConfig] block that will be applied into the `android` closure
|
||||
*
|
||||
* @param extraDefaultConfig [ExtraDefaultConfig] block that will be applied into the
|
||||
* `android.defaultConfig` closure
|
||||
* Dsl for apply the android configuration to a library or application module
|
||||
* @author Davide Farella
|
||||
*/
|
||||
fun TestedExtension.configApp(
|
||||
appId: String = Project.appId,
|
||||
fun org.gradle.api.Project.android(
|
||||
|
||||
appIdSuffix: String? = null,
|
||||
minSdk: Int = Project.minSdk,
|
||||
targetSdk: Int = Project.targetSdk,
|
||||
extraConfig: ExtraConfig = {},
|
||||
extraDefaultConfig: ExtraDefaultConfig = {}
|
||||
) = applyAndroidConfig(appId, minSdk, targetSdk, extraConfig, extraDefaultConfig)
|
||||
version: Version? = null,
|
||||
versionCode: Int = Project.versionCode,
|
||||
versionName: String = Project.versionName,
|
||||
config: ExtraConfig = {}
|
||||
|
||||
/**
|
||||
* Apply the default Android configuration a library modules
|
||||
*
|
||||
* @param extraConfig [ExtraConfig] block that will be applied into the `android` closure
|
||||
*
|
||||
* @param extraDefaultConfig [ExtraDefaultConfig] block that will be applied into the
|
||||
* `android.defaultConfig` closure
|
||||
*/
|
||||
fun TestedExtension.configLib(
|
||||
minSdk: Int = Project.minSdk,
|
||||
targetSdk: Int = Project.targetSdk,
|
||||
extraConfig: ExtraConfig = {},
|
||||
extraDefaultConfig: ExtraDefaultConfig = {}
|
||||
) = applyAndroidConfig(null, minSdk, targetSdk, extraConfig, extraDefaultConfig)
|
||||
) = (this as ExtensionAware).extensions.configure<TestedExtension> {
|
||||
|
||||
private fun TestedExtension.applyAndroidConfig(
|
||||
appId: String?,
|
||||
minSdk: Int,
|
||||
targetSdk: Int,
|
||||
extraConfig: ExtraConfig,
|
||||
extraDefaultConfig: ExtraDefaultConfig
|
||||
) {
|
||||
compileSdkVersion(Project.targetSdk)
|
||||
compileSdkVersion(targetSdk)
|
||||
defaultConfig {
|
||||
|
||||
// Params
|
||||
appId?.let { applicationId = it }
|
||||
versionCode = Project.versionCode
|
||||
versionName = Project.versionName
|
||||
appIdSuffix?.let { applicationId = "ch.protonmail.$it" }
|
||||
if (version != null) {
|
||||
this.version = version
|
||||
} else {
|
||||
this.versionCode = versionCode
|
||||
this.versionName = versionName
|
||||
}
|
||||
|
||||
// Sdk
|
||||
// SDK
|
||||
minSdkVersion(minSdk)
|
||||
targetSdkVersion(targetSdk)
|
||||
|
||||
|
@ -74,32 +59,53 @@ private fun TestedExtension.applyAndroidConfig(
|
|||
vectorDrawables.useSupportLibrary = true
|
||||
multiDexEnabled = true
|
||||
|
||||
extraDefaultConfig(this)
|
||||
// Annotation processors must be explicitly declared now. The following dependencies on
|
||||
// the compile classpath are found to contain annotation processor. Please add them to the
|
||||
// annotationProcessor configuration.
|
||||
// - auto-service-1.0-rc4.jar (com.google.auto.service:auto-service:1.0-rc4)
|
||||
//
|
||||
// Note that this option ( 👇 ) is deprecated and will be removed in the future.
|
||||
// See https://developer.android.com/r/tools/annotation-processor-error-message.html for
|
||||
// more details.
|
||||
javaCompileOptions.annotationProcessorOptions.includeCompileClasspath = true
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
register("releasePlayStore")
|
||||
register("releaseBeta")
|
||||
}
|
||||
|
||||
// Add support for `src/x/kotlin` instead of `src/x/java` only
|
||||
sourceSets {
|
||||
getByName("main").java.srcDirs("src/main/kotlin")
|
||||
getByName("test").java.srcDirs("src/test/kotlin")
|
||||
getByName("androidTest").java.srcDirs("src/androidTest/kotlin")
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility = Project.jdkVersion
|
||||
targetCompatibility = Project.jdkVersion
|
||||
}
|
||||
packagingOptions {
|
||||
exclude("go/error.java")
|
||||
exclude("go/LoadJNI.java")
|
||||
exclude("go/Seq.java")
|
||||
exclude("go/Universe.java")
|
||||
exclude("META-INF/atomicfu.kotlin_module")
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = sourceCompatibility
|
||||
}
|
||||
|
||||
extraConfig()
|
||||
testOptions {
|
||||
unitTests.isIncludeAndroidResources = true
|
||||
}
|
||||
|
||||
packagingOptions {
|
||||
exclude("META-INF/*.kotlin_module")
|
||||
exclude("META-INF/DEPENDENCIES")
|
||||
exclude("META-INF/DEPENDENCIES.txt")
|
||||
exclude("META-INF/LGPL2.1")
|
||||
exclude("META-INF/LICENSE")
|
||||
exclude("META-INF/LICENSE.md")
|
||||
exclude("META-INF/LICENSE.txt")
|
||||
exclude("META-INF/LICENSE-notice.md")
|
||||
exclude("META-INF/NOTICE")
|
||||
exclude("META-INF/NOTICE.txt")
|
||||
exclude("META-INF/rxjava.properties")
|
||||
}
|
||||
|
||||
apply(config)
|
||||
}
|
||||
|
||||
typealias ExtraConfig = TestedExtension.() -> Unit
|
||||
typealias ExtraDefaultConfig = DefaultConfig.() -> Unit
|
||||
|
|
|
@ -1,110 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2020 Proton Technologies AG
|
||||
*
|
||||
* This file is part of ProtonMail.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with ProtonMail. If not, see https://www.gnu.org/licenses/.
|
||||
*/
|
||||
import org.gradle.api.artifacts.ModuleDependency
|
||||
import org.gradle.api.artifacts.ProjectDependency
|
||||
import org.gradle.kotlin.dsl.exclude
|
||||
|
||||
/**
|
||||
* Dependency object for a library
|
||||
* @author Davide Farella
|
||||
*/
|
||||
interface Dependency {
|
||||
|
||||
/** Version of the dependency */
|
||||
val version: String
|
||||
|
||||
/** @return [List] of all the [DepGroup] for this [Dependency] */
|
||||
fun allGroups(): List<DepGroup>
|
||||
|
||||
/** @return [List] of all the [DepModule] for this [Dependency] */
|
||||
fun allModules() = allGroups().flatMap { it.all() }
|
||||
|
||||
|
||||
// region Constructor functions
|
||||
/** @return [DepModule] created with the receiver [DepGroup] as parent */
|
||||
fun DepGroup.module(module: String) = object : DepModule(this, module, version) {}
|
||||
|
||||
/** @return [ProjectPlugin] */
|
||||
fun DepGroup.projectPlugin(projectPluginName: String) = Plugin.pPlugin("$group:$projectPluginName", version)
|
||||
|
||||
/** @return [ModulePlugin] */
|
||||
fun DepGroup.modulePlugin(modulePluginId: String) = Plugin.mPlugin(modulePluginId)
|
||||
|
||||
/** @return [GradlePlugin] */
|
||||
fun DepGroup.gradlePlugin(projectPluginName: String, modulePluginId: String) =
|
||||
Plugin.gPlugin("$group:$projectPluginName", version, modulePluginId)
|
||||
// endregion
|
||||
}
|
||||
|
||||
/** Group of a [Dependency] */
|
||||
abstract class DepGroup(val group: String) {
|
||||
|
||||
/** @return [List] of all the [DepModule] for this [DepGroup] */
|
||||
abstract fun all(): List<DepModule>
|
||||
|
||||
/** Default implementation of [Dependency.allGroups] */
|
||||
open fun allGroups(): List<DepGroup> = listOf(this)
|
||||
|
||||
/** @return name of the group. [group] */
|
||||
override fun toString() = group
|
||||
}
|
||||
|
||||
/** Module of a [DepGroup] */
|
||||
abstract class DepModule(val group: DepGroup, val module: String, val version: String) {
|
||||
|
||||
/** @return path of the module. [group]:[module] */
|
||||
override fun toString() = "$group:$module"
|
||||
}
|
||||
|
||||
|
||||
// region Extensions
|
||||
/** @return [String] of the full dependency path */
|
||||
internal operator fun DepModule.invoke() = "$group:$module:$version"
|
||||
|
||||
/** @return [List] of [DepModule] created by the receiver and the param */
|
||||
internal operator fun DepModule.plus(other: DepModule) = listOf(this, other)
|
||||
|
||||
/** @return [List] of [DepGroup] created by the receiver and the param */
|
||||
internal operator fun DepGroup.plus(other: DepGroup) = listOf(this, other)
|
||||
// endregion
|
||||
|
||||
// region exclude utils
|
||||
fun ModuleDependency.exclude(vararg any: Any) {
|
||||
any.forEach {
|
||||
when(it) {
|
||||
is DepGroup -> exclude(it)
|
||||
is DepModule -> exclude(it)
|
||||
is List<*> -> it.forEach { e -> exclude(e!!) }
|
||||
else -> throw IllegalArgumentException(it.toString())
|
||||
}
|
||||
}
|
||||
}
|
||||
fun ModuleDependency.exclude(vararg groups: DepGroup) {
|
||||
groups.forEach(::exclude)
|
||||
}
|
||||
fun ModuleDependency.exclude(group: DepGroup) {
|
||||
group.all().forEach(::exclude)
|
||||
}
|
||||
fun ModuleDependency.exclude(vararg modules: DepModule) {
|
||||
modules.forEach(::exclude)
|
||||
}
|
||||
fun ModuleDependency.exclude(module: DepModule) {
|
||||
exclude(module.group.group, module.module)
|
||||
}
|
||||
// endregion
|
|
@ -1,41 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2020 Proton Technologies AG
|
||||
*
|
||||
* This file is part of ProtonMail.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with ProtonMail. If not, see https://www.gnu.org/licenses/.
|
||||
*/
|
||||
import org.gradle.kotlin.dsl.KotlinBuildScript
|
||||
import org.gradle.kotlin.dsl.apply
|
||||
import org.gradle.kotlin.dsl.withType
|
||||
import org.jetbrains.dokka.gradle.DokkaAndroidTask
|
||||
import java.io.File
|
||||
|
||||
/**
|
||||
* A script for apply Dokka Android Gradle plugin
|
||||
* @author Davide Farella
|
||||
*/
|
||||
@Suppress("unused")
|
||||
fun KotlinBuildScript.applyDokka() {
|
||||
apply(Plugin.android_library)
|
||||
apply(Plugin.kotlin_android)
|
||||
apply(Plugin.dokka_android)
|
||||
tasks.withType(DokkaAndroidTask::class) {
|
||||
apiVersion = Project.targetSdk.toString()
|
||||
jdkVersion = Project.jdkVersion.ordinal
|
||||
sourceDirs = listOf(File("src/main/kotlin"))
|
||||
outputFormat = "html"
|
||||
outputDirectory = "docs"
|
||||
}
|
||||
}
|
|
@ -16,18 +16,15 @@
|
|||
* You should have received a copy of the GNU General Public License
|
||||
* along with ProtonMail. If not, see https://www.gnu.org/licenses/.
|
||||
*/
|
||||
import org.gradle.api.JavaVersion
|
||||
|
||||
/**
|
||||
* Params for the Application and various modules
|
||||
* @author Davide Farella
|
||||
*/
|
||||
object Project {
|
||||
const val appId = "ch.protonmail.android"
|
||||
const val versionName = "1.12.3"
|
||||
const val versionCode = 687 // jenkinsBuildNumber.toInteger()
|
||||
const val versionName = "1.13.4"
|
||||
const val versionCode = 717
|
||||
|
||||
const val targetSdk = 28
|
||||
const val minSdk = 21
|
||||
val jdkVersion = JavaVersion.VERSION_1_8
|
||||
}
|
||||
|
|
|
@ -16,21 +16,20 @@
|
|||
* You should have received a copy of the GNU General Public License
|
||||
* along with ProtonMail. If not, see https://www.gnu.org/licenses/.
|
||||
*/
|
||||
@file:Suppress("PackageDirectoryMismatch")
|
||||
|
||||
import org.gradle.kotlin.dsl.DependencyHandlerScope
|
||||
import org.gradle.kotlin.dsl.ScriptHandlerScope
|
||||
import studio.forface.easygradle.dsl.*
|
||||
import studio.forface.easygradle.dsl.android.*
|
||||
|
||||
/**
|
||||
* Lambda that applies dependencies to the classpath
|
||||
* @author Davide Farella
|
||||
*/
|
||||
val ScriptHandlerScope.classpathDependencies: DependencyHandlerScope.() -> Unit get() = {
|
||||
addClasspath(Plugin.android)
|
||||
addClasspath(Plugin.dokka)
|
||||
addClasspath(Plugin.detekt)
|
||||
addClasspath(Plugin.hugo)
|
||||
addClasspath(Plugin.kotlin)
|
||||
addClasspath(Plugin.kotlin_serialization)
|
||||
addClasspath(Plugin.sonarQube)
|
||||
classpath(`android-gradle-plugin`)
|
||||
classpath(`detekt-plugin`)
|
||||
classpath(`hugo-plugin`)
|
||||
classpath(`kotlin-gradle-plugin`)
|
||||
classpath(`serialization-gradle-plugin`)
|
||||
classpath(`sentry-android-plugin`)
|
||||
}
|
|
@ -1,173 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2020 Proton Technologies AG
|
||||
*
|
||||
* This file is part of ProtonMail.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with ProtonMail. If not, see https://www.gnu.org/licenses/.
|
||||
*/
|
||||
@file:Suppress("PackageDirectoryMismatch")
|
||||
|
||||
// Android Arch
|
||||
object AndroidArch: Dependency, DepGroup("androidx.arch.core") {
|
||||
override val version = V.android_arch
|
||||
|
||||
val common = module("core-common")
|
||||
val testing = module("core-testing")
|
||||
|
||||
override fun all() = common + testing
|
||||
}
|
||||
|
||||
// Android Lifecycle
|
||||
object AndroidLifecycle: Dependency, DepGroup("androidx.lifecycle") {
|
||||
override val version = V.android_lifecycle
|
||||
|
||||
val extensions = module("lifecycle-extensions")
|
||||
val runtime = module("lifecycle-runtime") // TODO -ktx artifact available starting from 2.2.x
|
||||
val liveData = module("lifecycle-livedata-ktx")
|
||||
val viewModel = module("lifecycle-viewmodel-ktx")
|
||||
|
||||
override fun all() = extensions + runtime + liveData + viewModel
|
||||
}
|
||||
|
||||
// Android Test
|
||||
object AndroidTest: Dependency, DepGroup("androidx.test") {
|
||||
override val version = V.androidx_test
|
||||
|
||||
val core = module("core")
|
||||
val rules = module("rules")
|
||||
val runner = module("runner")
|
||||
|
||||
override fun all() = core + rules + runner
|
||||
}
|
||||
|
||||
// ButterKnife
|
||||
object ButterKnife: Dependency, DepGroup("com.jakewharton") {
|
||||
override val version = V.butterKnife
|
||||
|
||||
val runtime = module("butterknife")
|
||||
val compiler = module("butterknife-compiler")
|
||||
|
||||
override fun all() = runtime + compiler
|
||||
}
|
||||
|
||||
// Dagger
|
||||
object Dagger: Dependency, DepGroup("com.google.dagger") {
|
||||
override val version = V.dagger
|
||||
|
||||
val dagger = module("dagger")
|
||||
val android = module("dagger-android")
|
||||
val androidSupport = module("dagger-android-support")
|
||||
val compiler = module("dagger-compiler")
|
||||
val androidProcessor = module("dagger-android-processor")
|
||||
|
||||
override fun all() = dagger + android + androidSupport + compiler + androidProcessor
|
||||
}
|
||||
|
||||
// Hugo
|
||||
object Hugo: Dependency, DepGroup("com.jakewharton.hugo") {
|
||||
override val version = V.hugo
|
||||
|
||||
val annotations = module("hugo-annotations")
|
||||
val gradlePlugin = gradlePlugin("hugo-plugin", "com.jakewharton.hugo")
|
||||
|
||||
override fun all() = listOf(annotations)
|
||||
}
|
||||
|
||||
// JUnit 5
|
||||
object JUnit5: Dependency {
|
||||
override val version = V.jUnit5
|
||||
|
||||
object Jupiter : DepGroup("org.junit.jupiter") {
|
||||
val api = module("junit-jupiter-api")
|
||||
val engine = module("junit-jupiter-engine")
|
||||
val params = module("junit-jupiter-params")
|
||||
|
||||
override fun all() = api + engine + params
|
||||
}
|
||||
object Vintage : DepGroup("org.junit.vintage") {
|
||||
val engine = module("junit-vintage-engine")
|
||||
|
||||
override fun all() = listOf(engine)
|
||||
}
|
||||
|
||||
override fun allGroups() = Jupiter + Vintage
|
||||
}
|
||||
|
||||
// Kotlin
|
||||
object Kotlin : Dependency, DepGroup("org.jetbrains.kotlin") {
|
||||
override val version = V.kotlin
|
||||
|
||||
val jdk7 = module("kotlin-stdlib-jdk7")
|
||||
val reflect = module("kotlin-reflect")
|
||||
|
||||
val gradlePlugin = gradlePlugin("kotlin-gradle-plugin", "kotlin")
|
||||
val androidGradlePlugin = modulePlugin("kotlin-android")
|
||||
val androidExtGradlePlugin = modulePlugin("kotlin-android-extensions")
|
||||
|
||||
override fun all() = jdk7 + reflect
|
||||
}
|
||||
|
||||
// MockK
|
||||
object MockK: Dependency, DepGroup("io.mockk") {
|
||||
override val version = V.mockk
|
||||
|
||||
val mockk = module("mockk")
|
||||
val android = module("mockk-android")
|
||||
|
||||
override fun all() = mockk + android
|
||||
}
|
||||
|
||||
// Retrofit
|
||||
object Retrofit: Dependency, DepGroup("com.squareup.retrofit2") {
|
||||
override val version = V.retrofit
|
||||
|
||||
val retrofit = module("retrofit")
|
||||
val gson = module("converter-gson")
|
||||
val rxJava = module("adapter-rxjava2")
|
||||
|
||||
override fun all() = retrofit + gson + rxJava
|
||||
}
|
||||
|
||||
// Room
|
||||
object Room: Dependency, DepGroup("androidx.room") {
|
||||
override val version = V.android_room
|
||||
|
||||
val runtime = module("room-runtime")
|
||||
val ktx = module("room-ktx")
|
||||
val rxJava = module("room-rxjava2")
|
||||
val compiler = module("room-compiler")
|
||||
|
||||
override fun all() = runtime + ktx + rxJava + compiler
|
||||
}
|
||||
|
||||
// ViewStateStore
|
||||
object ViewStateStore: Dependency, DepGroup("studio.forface.viewstatestore") {
|
||||
override val version = V.viewStateStore
|
||||
|
||||
val viewStateStore = module("viewstatestore")
|
||||
val paging = module("viewstatestore-paging")
|
||||
|
||||
override fun all() = viewStateStore + paging
|
||||
}
|
||||
|
||||
// Sentry
|
||||
object Sentry: Dependency, DepGroup("io.sentry") {
|
||||
override val version = V.sentry
|
||||
|
||||
val sentry = module("sentry-android")
|
||||
val gradlePlugin = gradlePlugin("sentry-android-gradle-plugin","sentry")
|
||||
val sentryGradlePlugin = modulePlugin("io.sentry.android.gradle")
|
||||
|
||||
override fun all() = listOf(sentry)
|
||||
}
|
|
@ -1,103 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2020 Proton Technologies AG
|
||||
*
|
||||
* This file is part of ProtonMail.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with ProtonMail. If not, see https://www.gnu.org/licenses/.
|
||||
*/
|
||||
@file:Suppress("PackageDirectoryMismatch")
|
||||
|
||||
// TODO remove: workaround for nested object in Groovy
|
||||
object LibAndroid { val get = Lib.Android }
|
||||
|
||||
/**
|
||||
* Libraries used by the project
|
||||
* @author Davide Farella
|
||||
*/
|
||||
object Lib {
|
||||
|
||||
/* Kotlin */
|
||||
val kotlin = Kotlin.jdk7()
|
||||
const val coroutines = "org.jetbrains.kotlinx:kotlinx-coroutines-core:${V.coroutines}"
|
||||
const val coroutines_android = "org.jetbrains.kotlinx:kotlinx-coroutines-android:${V.coroutines}"
|
||||
val reflect = Kotlin.reflect()
|
||||
const val serialization = "org.jetbrains.kotlinx:kotlinx-serialization-runtime:${V.serialization}"
|
||||
|
||||
/* Test */
|
||||
object Test {
|
||||
val android_arch = AndroidArch.testing()
|
||||
val android_test_core = AndroidTest.core()
|
||||
val android_test_rules = AndroidTest.rules()
|
||||
val android_test_runner = AndroidTest.runner()
|
||||
const val assertJ = "org.assertj:assertj-core:${V.assertJ}"
|
||||
const val coroutines = "org.jetbrains.kotlinx:kotlinx-coroutines-test:${V.coroutines}"
|
||||
const val espresso = "androidx.test.espresso:espresso-core:${V.espresso}"
|
||||
const val hamcrest = "org.hamcrest:hamcrest-library:${V.hamcrest}"
|
||||
const val jUnit4 = "junit:junit:${V.jUnit4}"
|
||||
val jUnit5_jupiterApi = JUnit5.Jupiter.api()
|
||||
val jUnit5_jupiterEngine = JUnit5.Jupiter.engine()
|
||||
val jUnit5_jupiterParams = JUnit5.Jupiter.params()
|
||||
val jUnit5_vintageEngine = JUnit5.Vintage.engine()
|
||||
const val kotlin = "org.jetbrains.kotlin:kotlin-test:${V.kotlin}"
|
||||
const val kotlin_junit = "org.jetbrains.kotlin:kotlin-test-junit:${V.kotlin}"
|
||||
val mockk = MockK.mockk()
|
||||
val mockk_android = MockK.android()
|
||||
}
|
||||
|
||||
/* Android */
|
||||
object Android {
|
||||
const val annotations = "androidx.annotation:annotation:${V.android_annotations}"
|
||||
const val appcompat = "androidx.appcompat:appcompat:${V.android_support}"
|
||||
val arch_core = AndroidArch.common()
|
||||
const val biometric = "androidx.biometric:biometric:${V.android_biometric}"
|
||||
const val constraintLayout = "androidx.constraintlayout:constraintlayout:${V.android_constraintLayout}"
|
||||
const val espresso = "androidx.test.espresso:espresso-core:${V.android_espresso}"
|
||||
const val ktx = "androidx.core:core-ktx:${V.android_ktx}"
|
||||
val lifecycle_extensions = AndroidLifecycle.extensions()
|
||||
val lifecycle_runtime = AndroidLifecycle.runtime()
|
||||
val lifecycle_liveData = AndroidLifecycle.liveData()
|
||||
val lifecycle_viewModel = AndroidLifecycle.viewModel()
|
||||
const val material = "com.google.android.material:material:${V.android_material}"
|
||||
const val paging = "androidx.paging:paging-runtime-ktx:${V.android_paging}"
|
||||
const val palette = "androidx.palette:palette:${V.android_palette}"
|
||||
val room_compiler = Room.compiler()
|
||||
val room_ktx = Room.ktx()
|
||||
val room_runtime = Room.runtime()
|
||||
val room_rxJava = Room.rxJava()
|
||||
const val work = "androidx.work:work-runtime-ktx:${V.android_work}"
|
||||
}
|
||||
|
||||
/* Other */
|
||||
val butterKnife = ButterKnife.runtime()
|
||||
val butterKnife_compiler = ButterKnife.compiler()
|
||||
val dagger = Dagger.dagger()
|
||||
val dagger_android = Dagger.android()
|
||||
val dagger_androidSupport = Dagger.androidSupport()
|
||||
val dagger_compiler = Dagger.compiler()
|
||||
val dagger_androidProcessor = Dagger.androidProcessor()
|
||||
const val gson = "com.google.code.gson:gson:${V.gson}"
|
||||
val hugo_annotations = Hugo.annotations()
|
||||
const val okHttp_loggingInterceptor = "com.squareup.okhttp3:logging-interceptor:${V.okHttp3}"
|
||||
val retrofit = Retrofit.retrofit()
|
||||
val retrofit_gson = Retrofit.gson()
|
||||
val retrofit_rxJava = Retrofit.rxJava()
|
||||
const val rxJava_android = "io.reactivex.rxjava2:rxandroid:${V.rxJava}"
|
||||
const val rxRelay = "com.jakewharton.rxrelay2:rxrelay:${V.rxRelay}"
|
||||
const val stetho = "com.facebook.stetho:stetho:${V.stetho}"
|
||||
const val timber = "com.jakewharton.timber:timber:${V.timber}"
|
||||
const val trustKit = "com.datatheorem.android.trustkit:trustkit:${V.trustKit}"
|
||||
val viewStateStore = ViewStateStore.viewStateStore()
|
||||
val viewStateStore_paging = ViewStateStore.paging()
|
||||
val sentry = Sentry.sentry()
|
||||
}
|
|
@ -1,119 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2020 Proton Technologies AG
|
||||
*
|
||||
* This file is part of ProtonMail.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with ProtonMail. If not, see https://www.gnu.org/licenses/.
|
||||
*/
|
||||
@file:Suppress("PackageDirectoryMismatch")
|
||||
|
||||
import org.gradle.api.artifacts.dsl.DependencyHandler
|
||||
import org.gradle.api.initialization.dsl.ScriptHandler.CLASSPATH_CONFIGURATION
|
||||
import org.gradle.kotlin.dsl.KotlinBuildScript
|
||||
import org.gradle.kotlin.dsl.apply
|
||||
import org.gradle.plugin.use.PluginDependenciesSpec
|
||||
import org.gradle.plugin.use.PluginDependencySpec
|
||||
|
||||
/**
|
||||
* Gradle plugins for the project
|
||||
* @author Davide Farella
|
||||
*/
|
||||
object Plugin {
|
||||
val android = pPlugin("com.android.tools.build:gradle", V.android_gradle_plugin)
|
||||
val android_application = mPlugin("com.android.application")
|
||||
val android_library = mPlugin("com.android.library")
|
||||
|
||||
val dokka = gPlugin("org.jetbrains.dokka:dokka-android-gradle-plugin", V.publishing_dokka_plugin, "dokka")
|
||||
val dokka_android = mPlugin("dokka-android")
|
||||
|
||||
val hugo = Hugo.gradlePlugin
|
||||
|
||||
val java_library = mPlugin("java-library")
|
||||
|
||||
val kapt = mPlugin("kotlin-kapt")
|
||||
val sentry = Sentry.sentryGradlePlugin
|
||||
val detekt = pPlugin("io.gitlab.arturbosch.detekt:detekt-gradle-plugin", "1.5.0")
|
||||
val kotlin = Kotlin.gradlePlugin
|
||||
val kotlin_android = Kotlin.androidGradlePlugin
|
||||
val kotlin_android_extensions = Kotlin.androidExtGradlePlugin
|
||||
val kotlin_serialization = gPlugin("org.jetbrains.kotlin:kotlin-serialization", V.kotlin, "kotlinx-serialization")
|
||||
|
||||
val sonarQube = gPlugin("org.sonarsource.scanner.gradle:sonarqube-gradle-plugin", V.sonarQube, "org.sonarqube")
|
||||
}
|
||||
|
||||
/** A plugin intended to be applied to the classpath of the Project */
|
||||
interface ProjectPlugin {
|
||||
val path: String
|
||||
val version: String
|
||||
}
|
||||
|
||||
/** A plugin intended to be applied of a single Module of the Project */
|
||||
interface ModulePlugin {
|
||||
val id: String
|
||||
val version: String?
|
||||
}
|
||||
|
||||
/** Implements [ProjectPlugin] and [ModulePlugin] */
|
||||
interface GradlePlugin : ProjectPlugin, ModulePlugin
|
||||
|
||||
// region Constructor functions
|
||||
/** @return [ProjectPlugin] */
|
||||
@Suppress("unused") // restricted scope to Plugin object
|
||||
internal fun Plugin.pPlugin(partialPath: String, version: String) =
|
||||
object : ProjectPlugin {
|
||||
override val path = "$partialPath:$version"
|
||||
override val version = version
|
||||
}
|
||||
|
||||
/** @return [ModulePlugin] */
|
||||
@Suppress("unused") // restricted scope to Plugin object
|
||||
internal fun Plugin.mPlugin(id: String, version: String? = null) =
|
||||
object : ModulePlugin {
|
||||
override val id = id
|
||||
override val version = version
|
||||
}
|
||||
|
||||
/** @return [GradlePlugin] */
|
||||
@Suppress("unused") // restricted scope to Plugin object
|
||||
internal fun Plugin.gPlugin(partialPath: String, version: String, id: String) =
|
||||
object : GradlePlugin {
|
||||
override val path = "$partialPath:$version"
|
||||
override val id = id
|
||||
override val version = version
|
||||
}
|
||||
// endregion
|
||||
|
||||
// region Gradle helpers
|
||||
/** Add given [ProjectPlugin] to the classpath */
|
||||
internal fun DependencyHandler.addClasspath(plugin: ProjectPlugin) =
|
||||
add(CLASSPATH_CONFIGURATION, plugin.path)
|
||||
|
||||
/** Add the given [ModulePlugin] to a module */
|
||||
fun PluginDependenciesSpec.apply(plugin: ModulePlugin, withVersion: Boolean = false): PluginDependencySpec {
|
||||
if (plugin.id.isEmpty())
|
||||
throw UnsupportedOperationException("This plugin is not supposed to be applied to a module")
|
||||
|
||||
return id(plugin.id).apply { if (withVersion) version(plugin.version) }
|
||||
}
|
||||
|
||||
/** Add the given [ModulePlugin]s to a module */
|
||||
fun KotlinBuildScript.plugins(vararg plugins: ModulePlugin) {
|
||||
plugins.forEach {
|
||||
if (it.id.isEmpty())
|
||||
throw UnsupportedOperationException("This plugin is not supposed to be applied to a module")
|
||||
|
||||
apply(plugin = it.id)
|
||||
}
|
||||
}
|
||||
// endregion
|
|
@ -1,81 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2020 Proton Technologies AG
|
||||
*
|
||||
* This file is part of ProtonMail.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with ProtonMail. If not, see https://www.gnu.org/licenses/.
|
||||
*/
|
||||
@file:Suppress("PackageDirectoryMismatch")
|
||||
|
||||
/**
|
||||
* Versions of the various dependencies ( libraries or plugins )
|
||||
* @author Davide Farella
|
||||
*/
|
||||
internal object V {
|
||||
|
||||
// region Kotlin
|
||||
const val kotlin = "1.3.50" // Updated: Aug 22, 2019
|
||||
const val coroutines = "1.3.0-RC2" // Updated: Aug 09, 2019
|
||||
const val serialization = "0.11.1" // Updated: Jun 19, 2019
|
||||
// endregion
|
||||
|
||||
// region Tests
|
||||
const val androidx_test = "1.2.0" // Updated: May 31, 2019
|
||||
const val assertJ = "3.13.2" // Updated: Aug 04, 2019
|
||||
const val espresso = "3.2.0" // Updated: May 30, 2019
|
||||
const val hamcrest = "1.3" // Updated:
|
||||
const val jUnit4 = "4.12"
|
||||
const val jUnit5 = "5.5.0" // Updated:
|
||||
const val mockk = "1.9.3" // Updated: Mar 25, 2019
|
||||
// endregion
|
||||
|
||||
// region Android
|
||||
const val android_annotations = "1.1.0" // Updated: Jun 05, 2019
|
||||
const val android_arch = "2.1.0-rc01" // Updated: Jul 03, 2019
|
||||
const val android_biometric = "1.0.1" // Updated: Jan 23, 2020
|
||||
const val android_constraintLayout = "2.0.0-beta2" // Updated: Jun 17, 2019
|
||||
const val android_espresso = "3.2.0" // Updated: May 30, 2019
|
||||
const val android_gradle_plugin = "3.3.2" // Updated: Mar 04, 2019 TODO 3.4.x uses R8, so proguard rules must be revisited, specially for Gson and retrofit. https://r8.googlesource.com/r8/+/refs/heads/master/compatibility-faq.md
|
||||
const val android_ktx = "1.1.0-rc03" // Updated: Aug 09, 2019
|
||||
const val android_lifecycle = "2.1.0-rc01" // Updated: Jul 03, 2019
|
||||
const val android_material = "1.1.0-alpha09" // Updated: Jul 30, 2019
|
||||
const val android_paging = "2.1.0" // Updated: Jan 26, 2019
|
||||
const val android_palette = "1.0.0" // Updated: Sep 22, 2018
|
||||
const val android_room = "2.1.0" // Updated: Jun 14, 2019
|
||||
const val android_support = "1.2.0-alpha03" // Updated: Mar 26, 2020
|
||||
const val android_tools = "26.5.0-rc01" // Updated: Jul 17, 2019
|
||||
const val android_work = "2.1.0-beta01" // Updated:
|
||||
// endregion
|
||||
|
||||
// region Other
|
||||
const val butterKnife = "10.1.0" // Updated: Feb 14, 2019
|
||||
const val dagger = "2.16" // Updated: May 04, 2018 TODO: 2.24 removed `HasActivityInjector` in favor of `HasAndroidInjector`
|
||||
const val gson = "2.8.5" // Updated: May 22, 2018
|
||||
const val hugo = "1.2.1" // Updated: Feb 18, 2015
|
||||
const val okHttp3 = "3.12.5" // Updated: Sep 11, 2019 TODO: 4.x requires some refactor / 3.13+ requires minSDK 21
|
||||
const val retrofit = "2.6.1" // Updated: Jul 31, 2019
|
||||
const val rxJava = "2.0.2" // Updated: Dec 02, 2016
|
||||
const val rxRelay = "2.1.1" // Updated: Aug 23, 2019
|
||||
const val sonarQube = "2.7.1" // Updated: May 14, 2019
|
||||
const val stetho = "1.5.1" // Updated: Mar 18, 2019
|
||||
const val timber = "4.7.1" // Updated:
|
||||
const val trustKit = "1.1.2" // Updated: Jun 09, 2019
|
||||
const val viewStateStore = "1.3-alpha-1" // Updated: May 22, 2019
|
||||
const val sentry = "1.7.22" // Updated:
|
||||
// endregion
|
||||
|
||||
// region Publishing
|
||||
const val publishing_dokka_plugin = "0.9.18" // Updated: Mar 19, 2019
|
||||
// endregion
|
||||
}
|
|
@ -0,0 +1,87 @@
|
|||
/*
|
||||
* Copyright (c) 2020 Proton Technologies AG
|
||||
*
|
||||
* This file is part of ProtonMail.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with ProtonMail. If not, see https://www.gnu.org/licenses/.
|
||||
*/
|
||||
import org.gradle.api.artifacts.dsl.DependencyHandler
|
||||
import studio.forface.easygradle.dsl.*
|
||||
import studio.forface.easygradle.dsl.android.*
|
||||
|
||||
// region Android
|
||||
val DependencyHandler.`android-biometric` get() = androidx("biometric") version `android-biometric version`
|
||||
val DependencyHandler.`android-fragment` get() = androidx("fragment", moduleSuffix = "ktx") version `android-fragment version`
|
||||
val DependencyHandler.`android-media` get() = androidx("media") version `android-media version`
|
||||
val DependencyHandler.`gcm` get() = playServices("gcm")
|
||||
val DependencyHandler.`room-rxJava` get() = androidxRoom("rxjava2")
|
||||
val DependencyHandler.`safetyNet` get() = playServices("safetynet")
|
||||
|
||||
fun DependencyHandler.playServices(moduleSuffix: String, version: String = `playServices version`) =
|
||||
googleAndroid("gms", "play-services", moduleSuffix, version)
|
||||
// endregion
|
||||
|
||||
// region Test
|
||||
val DependencyHandler.`assertJ` get() = dependency("org.assertj", module = "assertj-core") version `assertJ version`
|
||||
val DependencyHandler.`hamcrest` get() = dependency("org.hamcrest", module = "hamcrest-library") version `hamcrest version`
|
||||
val DependencyHandler.`jUnit5-jupiter-api` get() = jUnit5jupiter("api")
|
||||
val DependencyHandler.`jUnit5-jupiter-engine` get() = jUnit5jupiter("engine")
|
||||
val DependencyHandler.`jUnit5-jupiter-params` get() = jUnit5jupiter("params")
|
||||
val DependencyHandler.`jUnit5-vintage-engine` get() = jUnit5vintage("engine")
|
||||
val DependencyHandler.`robolectric` get() = dependency("org.robolectric", module = "robolectric") version `robolectric version`
|
||||
|
||||
// region jUnit 5 groups
|
||||
fun DependencyHandler.jUnit5jupiter(moduleSuffix: String, version: String = `jUnit5 version`) =
|
||||
jUnit5("jupiter", "jupiter-$moduleSuffix", version)
|
||||
|
||||
fun DependencyHandler.jUnit5vintage(moduleSuffix: String, version: String = `jUnit5 version`) =
|
||||
jUnit5("vintage", "vintage-$moduleSuffix", version)
|
||||
|
||||
fun DependencyHandler.jUnit5(groupName: String, moduleSuffix: String, version: String = `jUnit5 version`) =
|
||||
dependency("org.junit", groupName, "junit", moduleSuffix, version)
|
||||
// endregion
|
||||
// endregion
|
||||
|
||||
// region Retrofit
|
||||
val DependencyHandler.`retrofit-gson` get() = squareup("retrofit2", "converter-gson") version `retrofit version`
|
||||
val DependencyHandler.`retrofit-rxJava` get() = squareup("retrofit2", "adapter-rxjava2") version `retrofit version`
|
||||
val DependencyHandler.`okHttp-loggingInterceptor` get() = squareup("okhttp3", "logging-interceptor") version `okHttp3 version`
|
||||
// endregion
|
||||
|
||||
// region RxJava
|
||||
val DependencyHandler.`rxJava-android` get() = dependency("io.reactivex", "rxjava2", "rxandroid") version `rxJava version`
|
||||
val DependencyHandler.`rxRelay` get() = jakeWharton("rxrelay2", "rxrelay") version `rxRelay version`
|
||||
// endregion
|
||||
|
||||
// region Other
|
||||
val DependencyHandler.`apache-commons-lang` get() = dependency("org.apache", "commons", moduleSuffix = "lang3") version `apache-commons-lang version`
|
||||
val DependencyHandler.`butterknife-runtime` get() = jakeWharton(module = "butterknife") version `butterKnife version`
|
||||
val DependencyHandler.`butterknife-compiler` get() = jakeWharton(module = "butterknife", moduleSuffix = "compiler") version `butterKnife version`
|
||||
val DependencyHandler.`detekt-plugin` get() = detekt("gradle-plugin")
|
||||
val DependencyHandler.`detekt-cli` get() = detekt("cli")
|
||||
val DependencyHandler.`detekt-formatting` get() = detekt("formatting")
|
||||
val DependencyHandler.`detekt-code-analysis` get() = dependency("pm.algirdas", "detekt", "codeanalysis") version `detect-code-analysis version`
|
||||
val DependencyHandler.`gson` get() = google("code.gson", "gson") version `gson version`
|
||||
val DependencyHandler.`hugo-annotations` get() = jakeWharton("hugo", moduleSuffix = "annotations") version `hugo version`
|
||||
val DependencyHandler.`hugo-plugin` get() = jakeWharton("hugo", moduleSuffix = "plugin") version `hugo version`
|
||||
val DependencyHandler.`jsoup` get() = dependency("org.jsoup", module = "jsoup") version `jsoup version`
|
||||
val DependencyHandler.`sentry-android` get() = dependency("io.sentry", module = "sentry-android") version `sentry version`
|
||||
val DependencyHandler.`sentry-android-plugin` get() = dependency("io.sentry", module = "sentry-android-gradle-plugin") version `sentry version`
|
||||
val DependencyHandler.`stetho` get() = dependency("com.facebook", "stetho") version `stetho version`
|
||||
val DependencyHandler.`timber` get() = jakeWharton("timber") version `timber version`
|
||||
val DependencyHandler.`trustKit` get() = dependency("com.datatheorem.android", "trustkit") version `trustKit version`
|
||||
|
||||
fun DependencyHandler.detekt(moduleSuffix: String, version: String = `detekt version`) =
|
||||
dependency("io.gitlab.arturbosch", groupName = "detekt", moduleSuffix = moduleSuffix, version = version)
|
||||
// endregion
|
|
@ -16,12 +16,6 @@
|
|||
* You should have received a copy of the GNU General Public License
|
||||
* along with ProtonMail. If not, see https://www.gnu.org/licenses/.
|
||||
*/
|
||||
@file:Suppress("PackageDirectoryMismatch")
|
||||
|
||||
/**
|
||||
* Internal modules of the project
|
||||
* @author Davide Farella
|
||||
*/
|
||||
object Module {
|
||||
// Libs
|
||||
const val tokenAutoComplete = ":tokenAutoComplete:tokenAutoComplete-lib"
|
||||
|
@ -31,3 +25,10 @@ object Module {
|
|||
const val testAndroid = ":sharedTest:testAndroid"
|
||||
const val testAndroidInstrumented = ":sharedTest:testAndroidInstrumented"
|
||||
}
|
||||
|
||||
/*** Internal libs */
|
||||
object Lib {
|
||||
@Suppress("unused") const val composer = "Composer"
|
||||
@Suppress("unused") const val composerTest = "Composer-test"
|
||||
const val protonCore = "Proton-core"
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* Copyright (c) 2020 Proton Technologies AG
|
||||
*
|
||||
* This file is part of ProtonMail.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with ProtonMail. If not, see https://www.gnu.org/licenses/.
|
||||
*/
|
||||
@file:Suppress(
|
||||
"ObjectPropertyName"
|
||||
)
|
||||
import org.gradle.kotlin.dsl.kotlin
|
||||
import org.gradle.kotlin.dsl.version
|
||||
import org.gradle.plugin.use.PluginDependenciesSpec
|
||||
import org.gradle.plugin.use.PluginDependencySpec
|
||||
|
||||
val PluginDependenciesSpec.`android-application` get() = plugin("com.android.application")
|
||||
val PluginDependenciesSpec.`android-library` get() = plugin("com.android.library")
|
||||
val PluginDependenciesSpec.`detekt` get() = plugin("io.gitlab.arturbosch.detekt")
|
||||
val PluginDependenciesSpec.`hugo` get() = plugin("com.jakewharton.hugo")
|
||||
val PluginDependenciesSpec.`java-library` get() = plugin("java-library")
|
||||
val PluginDependenciesSpec.`kotlin` get() = plugin("kotlin")
|
||||
val PluginDependenciesSpec.`kotlin-android` get() = kotlin("android")
|
||||
val PluginDependenciesSpec.`kotlin-android-extensions` get() = kotlin("android.extensions")
|
||||
val PluginDependenciesSpec.`kotlin-kapt` get() = kotlin("kapt")
|
||||
val PluginDependenciesSpec.`kotlin-serialization` get() = kotlin("plugin.serialization")
|
||||
val PluginDependenciesSpec.`sentry-android` get() = plugin("io.sentry.android.gradle")
|
||||
val PluginDependenciesSpec.`sonarQube` get() = plugin("org.sonarqube") version `sonarQube version`
|
||||
|
||||
|
||||
private fun PluginDependenciesSpec.plugin(id: String): PluginDependencySpec = id(id)
|
|
@ -0,0 +1,94 @@
|
|||
/*
|
||||
* Copyright (c) 2020 Proton Technologies AG
|
||||
*
|
||||
* This file is part of ProtonMail.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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.*
|
||||
|
||||
/** Initialize Easy Gradle versions */
|
||||
fun initVersions() {
|
||||
|
||||
// region Kotlin
|
||||
`kotlin version` = "1.3.70" // Released: Mar 03, 2020
|
||||
`coroutines version` = "1.3.4" // Released: Mar 06, 2020
|
||||
`serialization version` = "0.20.0" // Released: Mar 04, 2020
|
||||
// endregion
|
||||
|
||||
// region Android
|
||||
`android-gradle-plugin version` = "3.6.0" // Released: Feb 20, 2020
|
||||
|
||||
`android-annotation version` = "1.1.0" // Released: Jun 05, 2019
|
||||
`appcompat version` = "1.1.0" // Released: Sep 06, 2019
|
||||
`android-arch version` = "2.1.0" // Released: Sep 06, 2019
|
||||
`constraint-layout version` = "2.0.0-beta2" // Released: Jun 17, 2019
|
||||
`dagger version` = "2.16" // Released: May 04, 2018 TODO: 2.24 removed `HasActivityInjector` in favor of `HasAndroidInjector
|
||||
`espresso version` = "3.2.0" // Released: May 30, 2019
|
||||
`ktx version` = "1.2.0-rc01" // Released: Nov 23, 2019
|
||||
`lifecycle version` = "2.2.0-rc03" // Released: Dec 05, 2019
|
||||
`material version` = "1.1.0-beta02" // Released: Nov 10, 2019
|
||||
`android-paging version` = "2.1.0" // Released: Jan 26, 2019
|
||||
`android-room version` = "2.2.1" // Released: Oct 23, 2019
|
||||
`android-work version` = "2.2.0" // Released: Aug 16, 2019
|
||||
|
||||
`android-test version` = "1.2.0" // Released: May 31, 2019
|
||||
// endregion
|
||||
|
||||
// region Others
|
||||
`mockK version` = "1.9.3"
|
||||
`retrofit version` = "2.6.1" // Released: Jul 31, 2019
|
||||
`retrofit-kotlin-serialization version` = ""
|
||||
`viewStateStore version` = "1.4-beta-4" // Released: Mar 02, 2020
|
||||
// endregion
|
||||
}
|
||||
|
||||
// Proton Libs
|
||||
@Suppress("unused")
|
||||
const val `composer version` = "1.0-beta-3" // Released: Feb 12, 2020
|
||||
const val `protonCore version` = "0.2.21" // Released: Mar 13, 2020
|
||||
|
||||
// Test
|
||||
const val `assertJ version` = "3.13.2" // Released: Aug 04, 2019
|
||||
const val `hamcrest version` = "1.3" // Released:
|
||||
const val `jUnit5 version` = "5.5.0" // Released:
|
||||
const val `robolectric version` = "4.3.1" // Released: Oct 11, 2019
|
||||
|
||||
// Android
|
||||
const val `android-biometric version` = "1.0.1" // Released: Jan 23, 2020
|
||||
const val `android-fragment version` = "1.2.0-rc01" // Released: Oct 24, 2019
|
||||
const val `android-media version` = "1.1.0" // Released: Sep 06, 2019
|
||||
const val `android-palette version` = "1.0.0" // Released: Sep 22, 2018
|
||||
const val `gcm version` = "15.0.1" // Released:
|
||||
const val `playServices version` = "17.0.0" // Released: Jun 19, 2019
|
||||
|
||||
// Other
|
||||
const val `apache-commons-lang version` = "3.4" // Released: Apr 03, 2015
|
||||
const val `butterKnife version` = "10.1.0" // Released: Feb 14, 201
|
||||
const val `detekt version` = "1.8.0" // Released: Apr 25, 2020
|
||||
const val `detect-code-analysis version` = "0.2.2" // Released:
|
||||
const val `gson version` = "2.8.5" // Released: May 22, 201
|
||||
const val `hugo version` = "1.2.1" // Released: Feb 18, 201
|
||||
const val `jsoup version` = "1.8.3" // Released: Aug 02, 2015
|
||||
const val `okHttp3 version` = "3.12.5" // Released: Sep 11, 2019 TODO: 4.x requires some refactor / 3.13+ requires minSDK 2
|
||||
const val `rxJava version` = "2.0.2" // Released: Dec 02, 201
|
||||
const val `rxRelay version` = "2.1.1" // Released: Aug 23, 201
|
||||
const val `sentry version` = "1.7.22" // Released: Mar 13, 2019
|
||||
const val `sonarQube version` = "2.7.1" // Released: May 14, 201
|
||||
const val `stetho version` = "1.5.1" // Released: Mar 18, 201
|
||||
const val `timber version` = "4.7.1" // Released:
|
||||
const val `trustKit version` = "1.1.2" // Released: Jun 09, 2019
|
||||
|
|
@ -16,9 +16,11 @@
|
|||
# This option should only be used with decoupled projects. More details, visit
|
||||
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
|
||||
# org.gradle.parallel=true
|
||||
jenkinsBuildNumber=1
|
||||
android.useDeprecatedNdk=true
|
||||
org.gradle.jvmargs=-Xmx2048M
|
||||
kotlin.coroutines=enable
|
||||
android.useAndroidX=true
|
||||
android.enableJetifier=true
|
||||
android.enableJetifier=true
|
||||
|
||||
# App
|
||||
DATABASE_VERSION=1
|
||||
|
|
Binary file not shown.
|
@ -1,4 +1,3 @@
|
|||
#Mon Oct 01 11:02:58 CEST 2018
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
|
|
Binary file not shown.
|
@ -32,19 +32,23 @@ val EXTENSIONS = arrayOf("kt", "kts", "java", "xml")
|
|||
|
||||
/** Find the root dir of our project. `` **./proton-mail-android `` */
|
||||
val ROOT_DIR = with(StringBuilder(File("").absolutePath)) {
|
||||
if (last() == File.separatorChar) deleteCharAt(lastIndex)
|
||||
// Path for CLI gradle commands is usually '/Users/<username>/.gradle/<gradle-version>', so in
|
||||
// these situations we cannot get the root of our Project
|
||||
if (".gradle" in toString()) return@with null
|
||||
|
||||
var current = ""
|
||||
while (current != "proton-mail-android") {
|
||||
val lastSeparatorIndex = indexOfLast { it == File.separatorChar }
|
||||
current = substring(lastSeparatorIndex + 1..lastIndex)
|
||||
delete(lastSeparatorIndex, length)
|
||||
}
|
||||
if (last() == File.separatorChar) deleteCharAt(lastIndex)
|
||||
|
||||
val path = toString() + File.separator + current
|
||||
return@with File(path)
|
||||
var current = ""
|
||||
while (current != "proton-mail-android") {
|
||||
val lastSeparatorIndex = indexOfLast { it == File.separatorChar }
|
||||
current = substring(lastSeparatorIndex + 1..lastIndex)
|
||||
delete(lastSeparatorIndex, length)
|
||||
}
|
||||
|
||||
val path = toString() + File.separator + current
|
||||
return@with File(path)
|
||||
}
|
||||
|
||||
val LICENSE = """
|
||||
Copyright (c) 2020 Proton Technologies AG
|
||||
|
||||
|
@ -151,7 +155,12 @@ fun File.addLicense(): Boolean {
|
|||
temp.renameTo(this)
|
||||
|
||||
} catch (e: IOException) {
|
||||
throw IOException(e.message + " for file ${this.absolutePath}")
|
||||
if (e.message == "File $path is empty.") {
|
||||
// Delete file if is empty
|
||||
delete()
|
||||
} else {
|
||||
throw IOException(e.message + " for file ${this.absolutePath}")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -165,9 +174,11 @@ fun licenseFor(file: File) = _licensesByExtension[file.extension]
|
|||
|
||||
|
||||
|
||||
println()
|
||||
println("Using dir: ${ROOT_DIR.absolutePath}")
|
||||
println("Found: ${ROOT_DIR.children().size} files")
|
||||
println("Updated: ${ROOT_DIR.children().filter { it.addLicense() }.size} files")
|
||||
println()
|
||||
ROOT_DIR?.run {
|
||||
println()
|
||||
println("Using dir: ${absolutePath}")
|
||||
println("Found: ${children().size} files")
|
||||
println("Updated: ${children().filter { it.addLicense() }.size} files")
|
||||
println()
|
||||
}
|
||||
|
||||
|
|
|
@ -16,34 +16,49 @@
|
|||
* 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.*
|
||||
|
||||
plugins {
|
||||
apply(Plugin.android_library)
|
||||
apply(Plugin.kotlin_android)
|
||||
apply(Plugin.kotlin_android_extensions)
|
||||
`android-library`
|
||||
`kotlin-android`
|
||||
`kotlin-android-extensions`
|
||||
}
|
||||
|
||||
android { configLib() }
|
||||
android()
|
||||
|
||||
dependencies {
|
||||
// region base dependencies
|
||||
// Kotlin
|
||||
implementation(Lib.kotlin)
|
||||
implementation(Lib.coroutines_android)
|
||||
|
||||
// Android
|
||||
implementation(Lib.Android.lifecycle_runtime)
|
||||
implementation(Lib.Android.lifecycle_liveData)
|
||||
implementation(Lib.Android.lifecycle_viewModel)
|
||||
// Base dependencies
|
||||
implementation(
|
||||
// Kotlin
|
||||
`kotlin-jdk7`,
|
||||
`coroutines-android`,
|
||||
`serialization`,
|
||||
|
||||
// RxJava
|
||||
implementation(Lib.rxJava_android)
|
||||
// endregion
|
||||
// Android
|
||||
`constraint-layout`,
|
||||
`material`,
|
||||
`lifecycle-runtime`,
|
||||
`lifecycle-liveData`,
|
||||
`lifecycle-viewModel`,
|
||||
|
||||
// Proton Libs
|
||||
rootProject.aar(Lib.protonCore, version = `protonCore version`),
|
||||
// rootProject.aar(Lib.composer, version = `composer version`),
|
||||
|
||||
// region test dependencies
|
||||
api(project(Module.testKotlin))
|
||||
// RxJava
|
||||
`rxJava-android`
|
||||
)
|
||||
|
||||
// Android
|
||||
api(Lib.Test.android_arch)
|
||||
// endregion
|
||||
// Test dependencies
|
||||
api(
|
||||
project(Module.testKotlin),
|
||||
// rootProject.aar(Lib.composerTest, version = `composer version`),
|
||||
|
||||
// Android
|
||||
`android-test-core`,
|
||||
`android-arch-testing`,
|
||||
`robolectric`
|
||||
)
|
||||
}
|
||||
|
|
|
@ -16,45 +16,53 @@
|
|||
* 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.*
|
||||
|
||||
plugins {
|
||||
apply(Plugin.android_library)
|
||||
apply(Plugin.kotlin_android)
|
||||
apply(Plugin.kotlin_android_extensions)
|
||||
`android-library`
|
||||
`kotlin-android`
|
||||
`kotlin-android-extensions`
|
||||
}
|
||||
|
||||
android { configLib() }
|
||||
android()
|
||||
|
||||
dependencies {
|
||||
// region base dependencies
|
||||
// Kotlin
|
||||
implementation(Lib.kotlin)
|
||||
implementation(Lib.coroutines_android)
|
||||
|
||||
// Android
|
||||
implementation(Lib.Android.lifecycle_runtime)
|
||||
implementation(Lib.Android.lifecycle_liveData)
|
||||
implementation(Lib.Android.lifecycle_viewModel)
|
||||
// endregion
|
||||
// Base dependencies
|
||||
implementation(
|
||||
// Kotlin
|
||||
`kotlin-jdk7`,
|
||||
`coroutines-android`,
|
||||
|
||||
// region test dependencies
|
||||
api(project(Module.testAndroid)) {
|
||||
// Exclude MockK since we will use MockK-Android
|
||||
// Exclude JUnit 5 since we will use JUnit 4 on instrumented tests
|
||||
exclude(MockK.mockk, JUnit5.allModules())
|
||||
}
|
||||
// Android
|
||||
`lifecycle-runtime`,
|
||||
`lifecycle-liveData`,
|
||||
`lifecycle-viewModel`
|
||||
)
|
||||
|
||||
// jUnit 4
|
||||
api(Lib.Test.jUnit4)
|
||||
// Test dependencies
|
||||
api(
|
||||
project(Module.testAndroid).apply {
|
||||
exclude(
|
||||
// Exclude MockK since we will use MockK-Android
|
||||
`mockk`,
|
||||
// Exclude JUnit 5 since we will use JUnit 4 on instrumented tests
|
||||
jUnit5(`any`, `any`),
|
||||
// Exclude Robolectric since not needed for instrumented tests
|
||||
`robolectric`
|
||||
)
|
||||
},
|
||||
|
||||
// MockK
|
||||
api(Lib.Test.mockk_android)
|
||||
// MockK
|
||||
`mockk-android`,
|
||||
|
||||
// Android
|
||||
api(Lib.Android.annotations)
|
||||
api(Lib.Test.android_test_core)
|
||||
api(Lib.Test.android_test_runner)
|
||||
api(Lib.Test.android_test_rules)
|
||||
api(Lib.Test.espresso)
|
||||
api(Lib.Test.hamcrest)
|
||||
// endregion
|
||||
// Android
|
||||
`android-annotation`,
|
||||
`android-test-core`,
|
||||
`android-test-runner`,
|
||||
`android-test-rules`,
|
||||
`espresso`,
|
||||
`hamcrest`
|
||||
)
|
||||
}
|
||||
|
|
|
@ -16,42 +16,47 @@
|
|||
* 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.*
|
||||
|
||||
plugins {
|
||||
apply(Plugin.java_library)
|
||||
apply(Plugin.kotlin)
|
||||
`java-library`
|
||||
`kotlin`
|
||||
}
|
||||
|
||||
dependencies {
|
||||
// region base dependencies
|
||||
// Kotlin
|
||||
implementation(Lib.kotlin)
|
||||
implementation(Lib.coroutines)
|
||||
// Base dependencies
|
||||
implementation(
|
||||
`kotlin-jdk8`,
|
||||
`coroutines-core`,
|
||||
`serialization`
|
||||
)
|
||||
// endregion
|
||||
|
||||
|
||||
// region test dependencies
|
||||
api(`kotlin-test`, `kotlin-test-junit`)
|
||||
|
||||
// region jUnit 5
|
||||
|
||||
// (Required) Writing and executing Unit Tests on the JUnit Platform
|
||||
api(Lib.Test.jUnit5_jupiterApi)
|
||||
testRuntimeOnly(Lib.Test.jUnit5_jupiterEngine)
|
||||
api(`jUnit5-jupiter-api`)
|
||||
testRuntimeOnly(`jUnit5-jupiter-engine`)
|
||||
|
||||
// (Optional) If you need "Parameterized Tests"
|
||||
api(Lib.Test.jUnit5_jupiterParams)
|
||||
api(`jUnit5-jupiter-params`)
|
||||
|
||||
// (Optional) If you also have JUnit 4-based tests
|
||||
api(Lib.Test.jUnit4)
|
||||
testRuntimeOnly(Lib.Test.jUnit5_vintageEngine)
|
||||
testRuntimeOnly(`jUnit5-vintage-engine`)
|
||||
|
||||
// endregion
|
||||
|
||||
// Assertion
|
||||
api(Lib.Test.assertJ)
|
||||
api(`assertJ`)
|
||||
|
||||
// MockK
|
||||
api(Lib.Test.mockk)
|
||||
api(`mockk`)
|
||||
|
||||
// Kotlin
|
||||
api(Lib.Test.coroutines)
|
||||
api(`coroutines-test`)
|
||||
// endregion
|
||||
}
|
||||
|
|
|
@ -16,22 +16,30 @@
|
|||
* 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.*
|
||||
|
||||
plugins {
|
||||
apply(Plugin.android_application)
|
||||
apply(Plugin.kotlin_android)
|
||||
apply(Plugin.kotlin_android_extensions)
|
||||
`android-application`
|
||||
`kotlin-android`
|
||||
`kotlin-android-extensions`
|
||||
}
|
||||
|
||||
android { configApp("ch.protonmail.tokenautocomplete.example") }
|
||||
android("tokenautocomplete.example")
|
||||
|
||||
dependencies {
|
||||
implementation(Lib.kotlin)
|
||||
implementation(Lib.Android.appcompat)
|
||||
implementation(Lib.Android.annotations)
|
||||
implementation(Lib.Android.lifecycle_liveData)
|
||||
|
||||
implementation(project(Module.tokenAutoComplete))
|
||||
implementation(
|
||||
project(Module.tokenAutoComplete),
|
||||
|
||||
`kotlin-jdk7`,
|
||||
`coroutines-android`,
|
||||
`appcompat`,
|
||||
`android-annotation`,
|
||||
`lifecycle-runtime`,
|
||||
`lifecycle-liveData`,
|
||||
`lifecycle-viewModel`
|
||||
)
|
||||
|
||||
testImplementation(project(Module.testAndroid))
|
||||
androidTestImplementation(project(Module.testAndroidInstrumented))
|
||||
}
|
||||
|
|
|
@ -16,20 +16,27 @@
|
|||
* 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.*
|
||||
|
||||
plugins {
|
||||
apply(Plugin.android_library)
|
||||
apply(Plugin.kotlin_android)
|
||||
apply(Plugin.kotlin_android_extensions)
|
||||
`android-library`
|
||||
`kotlin-android`
|
||||
`kotlin-android-extensions`
|
||||
}
|
||||
|
||||
android { configLib() }
|
||||
android()
|
||||
|
||||
dependencies {
|
||||
implementation(Lib.kotlin)
|
||||
implementation(Lib.Android.appcompat) { exclude(AndroidArch, AndroidLifecycle) }
|
||||
implementation(Lib.Android.annotations)
|
||||
compileOnly(Lib.Android.arch_core)
|
||||
implementation(
|
||||
`kotlin-jdk7`,
|
||||
`appcompat`,
|
||||
`android-annotation`,
|
||||
|
||||
// Lifecycle
|
||||
`lifecycle-runtime`
|
||||
)
|
||||
|
||||
testImplementation(project(Module.testAndroid))
|
||||
androidTestImplementation(project(Module.testAndroidInstrumented)) { exclude(AndroidArch, AndroidLifecycle) }
|
||||
androidTestImplementation(project(Module.testAndroidInstrumented))
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue