Revision control

Copy as Markdown

//noinspection GradleDependency
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
plugins {
id 'com.android.application'
id 'androidx.navigation.safeargs'
id 'kotlin-android-extensions'
id 'kotlin-android'
id 'io.sentry.android.gradle'
id 'jacoco'
id "com.jetbrains.python.envs" version "0.0.26"
}
android {
compileSdkVersion 29
defaultConfig {
applicationId "mozilla.lockbox"
minSdkVersion 24
//noinspection OldTargetApi
targetSdkVersion 29
versionCode 6584
versionName "4.0.3"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
// The following argument makes the Android Test Orchestrator run its
// "pm clear" command after each test invocation. This command ensures
// that the app's state is completely cleared between tests.
testInstrumentationRunnerArguments clearPackageData: 'true'
buildConfigField "int", "BITRISE_BUILD_NUMBER", System.getenv("BITRISE_BUILD_NUMBER") ?: "0"
}
buildTypes {
debug {
debuggable true
testCoverageEnabled true
}
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
lintOptions {
disable 'GradleDependency'
lintConfig file("lint-config.xml")
warningsAsErrors true
baseline file("lint-baseline.xml")
}
testOptions {
unitTests {
includeAndroidResources = true
returnDefaultValues = true
}
execution 'ANDROIDX_TEST_ORCHESTRATOR'
}
packagingOptions {
exclude 'META-INF/LICENSE.md'
exclude 'META-INF/LICENSE-notice.md'
exclude 'META-INF/atomicfu.kotlin_module'
}
}
configurations {
ktlint
}
// Disabling LeakCanary in JVM tests per https://github.com/square/leakcanary/wiki/FAQ
configurations.all { config ->
if (config.name.contains('UnitTest')) {
config.resolutionStrategy.eachDependency { details ->
if (details.requested.group == 'com.squareup.leakcanary' && details.requested.name == 'leakcanary-android') {
details.useTarget(group: details.requested.group, name: 'leakcanary-android-no-op', version: details.requested.version)
}
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'com.google.android.material:material:1.2.0-alpha01'
implementation "androidx.recyclerview:recyclerview:$recyclerview_version"
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.exifinterface:exifinterface:1.0.0'
implementation "androidx.constraintlayout:constraintlayout:${constraintlayout_version}"
implementation "androidx.preference:preference:$preferences_version"
implementation "com.jakewharton.rxbinding2:rxbinding:${rxbinding_version}"
implementation "com.jakewharton.rxbinding2:rxbinding-design-kotlin:${rxbinding_version}"
implementation "com.jakewharton.rxbinding2:rxbinding-appcompat-v7-kotlin:${rxbinding_version}"
implementation "com.jakewharton.rxbinding2:rxbinding-recyclerview-v7-kotlin:${rxbinding_version}"
implementation "com.jakewharton.rxbinding2:rxbinding-support-v4-kotlin:${rxbinding_version}"
implementation 'com.jakewharton.rxrelay2:rxrelay:2.0.0'
implementation 'com.f2prateek.rx.preferences2:rx-preferences:2.0.0'
implementation 'io.reactivex.rxjava2:rxkotlin:2.3.0'
implementation 'io.reactivex.rxjava2:rxandroid:2.1.0'
implementation "org.mozilla.components:service-sync-logins:${rootProject.ext.android_components_version}"
implementation "org.mozilla.components:service-firefox-accounts:${rootProject.ext.android_components_version}"
implementation "org.mozilla.components:service-telemetry:${rootProject.ext.android_components_version}"
implementation "org.mozilla.components:service-glean:${rootProject.ext.android_components_version}"
implementation "org.mozilla.components:lib-dataprotect:${rootProject.ext.android_components_version}"
implementation "org.mozilla.components:lib-fetch-httpurlconnection:${rootProject.ext.android_components_version}"
implementation "org.mozilla.components:lib-publicsuffixlist:${rootProject.ext.android_components_version}"
implementation "org.mozilla.components:support-rusthttp:${rootProject.ext.android_components_version}"
implementation "org.mozilla.components:support-rustlog:${rootProject.ext.android_components_version}"
implementation "org.mozilla.components:concept-sync:${rootProject.ext.android_components_version}"
implementation "io.sentry:sentry-android:$sentry_version"
implementation "com.squareup.picasso:picasso:$picasso_version"
implementation project(":thirdparty")
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutine_version"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutine_version"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-rx2:$coroutine_version"
debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.6.2'
releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.6.2'
testImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.6.2'
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0-alpha03'
implementation 'androidx.lifecycle:lifecycle-common-java8:2.2.0-alpha03'
implementation "android.arch.navigation:navigation-fragment:$navigation_version"
implementation "android.arch.navigation:navigation-ui-ktx:$navigation_version"
implementation 'com.adjust.sdk:adjust-android:4.17.0'
implementation 'com.android.installreferrer:installreferrer:1.0'
implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
testImplementation 'junit:junit:4.12'
testImplementation 'org.mockito:mockito-core:2.24.5'
testImplementation 'org.robolectric:robolectric:4.2.1'
testImplementation "org.powermock:powermock-module-junit4:2.0.0-beta.5"
testImplementation "org.powermock:powermock-api-mockito2:2.0.0-beta.5"
testImplementation "org.junit.jupiter:junit-jupiter-api:5.3.1"
androidTestImplementation "org.junit.jupiter:junit-jupiter-api:5.3.1"
testImplementation "androidx.test:core:$androidxTest_version"
androidTestImplementation "androidx.test.ext:junit:$androidxTest_version"
androidTestImplementation "androidx.test:runner:$androidxTest_version"
androidTestImplementation "androidx.test:rules:$androidxTest_version"
androidTestUtil "androidx.test:orchestrator:$androidxTest_version"
androidTestImplementation 'org.mockito:mockito-android:2.22.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-intents:3.2.0'
androidTestImplementation("androidx.test.espresso:espresso-contrib:3.1.1") {
exclude group: 'com.android.support', module: 'appcompat'
exclude group: 'com.android.support', module: 'support-v4'
exclude group: 'com.android.support', module: 'support-v7'
exclude group: 'com.android.support', module: 'design'
exclude module: 'support-annotations'
exclude module: 'recyclerview-v7'
}
androidTestImplementation 'br.com.concretesolutions:kappuccino:1.2.1'
ktlint "com.github.shyiko:ktlint:0.28.0"
androidTestImplementation "tools.fastlane:screengrab:1.2.0"
modules {
module('org.mozilla.appservices:full-megazord') {
replacedBy('org.mozilla.appservices:lockbox-megazord', 'prefer the lockbox megazord, to reduce final application size')
}
module('org.mozilla.appservices:lockbox-megazord') {
replacedBy('org.mozilla.appservices:lockbox-megazord-forUnitTests', 'prefer the forUnitTests variant if present')
}
}
}
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 false
// 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
}
def outputDir = "${project.buildDir}/reports/ktlint/"
task ktlint(type: JavaExec, group: "verification", description: "Runs ktlint.") {
inputs.files(fileTree(dir: "src", include: "**/*.kt"),
fileTree(dir: ".", include: "**/.editorconfig"))
outputs.dir(outputDir)
main = "com.github.shyiko.ktlint.Main"
classpath = configurations.ktlint
args = ["--reporter=plain",
"--reporter=checkstyle,output=${outputDir}ktlint-checkstyle-report.xml",
"src/**/*.kt"]
}
afterEvaluate {
check.dependsOn ktlint
lint.dependsOn ktlint
lintDebug.dependsOn ktlint
}
task ktlintFormat(type: JavaExec, group: "formatting") {
inputs.files(
fileTree(dir: "src", include: "**/*.kt"),
fileTree(dir: ".", include: "**/.editorconfig")
)
outputs.upToDateWhen { true }
description = "Runs ktlint and autoformats your code."
main = "com.github.shyiko.ktlint.Main"
classpath = configurations.ktlint
args = ["-F", "src/**/*.kt"]
}
androidExtensions {
experimental = true
}
configurations.all { config ->
if (config.name.contains('Test')) {
config.resolutionStrategy.eachDependency { details ->
if (details.requested.group == 'com.squareup.leakcanary' && details.requested.name == 'leakcanary-android') {
details.useTarget(group: details.requested.group, name: 'leakcanary-android-no-op', version: details.requested.version)
}
}
}
}
// Set up jacoco for code coverage.
if (project.hasProperty("coverage")) {
tasks.withType(Test) {
jacoco.includeNoLocationClasses = true
}
android.applicationVariants.all { variant ->
// We dynamically generate our jacoco tasks to avoid creating too many build variants,
// which takes up space in AS despite not being run by most users and it can accidentally
// be run during CI with commands like `./gradlew test`, taking up more build time.
task "jacoco${variant.name.capitalize()}TestReport"(type: JacocoReport,
dependsOn: ["test${variant.name.capitalize()}UnitTest"]) {
reports {
html.enabled true
xml.enabled true
}
def fileFilter = ['**/R.class', '**/R$*.class', '**/BuildConfig.*', '**/Manifest*.*',
'**/*Test*.*', 'android/**/*.*', '**/*$[0-9].*']
def kotlinTree = fileTree(dir: "$project.buildDir/tmp/kotlin-classes/${variant.name}", excludes: fileFilter)
def javaTree = fileTree(dir: "$project.buildDir/intermediates/classes/${variant.flavorName}/${variant.buildType.name}",
excludes: fileFilter)
def mainSrc = "$project.projectDir/src/main/java"
sourceDirectories = files([mainSrc])
classDirectories = files([kotlinTree, javaTree])
executionData = fileTree(dir: project.buildDir, includes: [
"jacoco/test${variant.name.capitalize()}UnitTest.exec", 'outputs/code-coverage/connected/*coverage.ec'
])
}
}
android {
buildTypes {
debug {
testCoverageEnabled true
applicationIdSuffix ".coverage"
}
}
}
}
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
kotlinOptions.allWarningsAsErrors = true
}
// Generate markdown docs for the collected metrics.
ext.gleanGenerateMarkdownDocs = true
ext.gleanDocsDirectory = "$rootDir/docs/glean"
apply from: 'https://github.com/mozilla-mobile/android-components/raw/v' + rootProject.ext.android_components_version + '/components/service/glean/scripts/sdk_generator.gradle'
// Internal, but stable and convenient.
import org.gradle.api.internal.artifacts.DefaultModuleIdentifier