2024-01-03 01:31:45 +03:00
|
|
|
import com.google.firebase.crashlytics.buildtools.gradle.tasks.InjectMappingFileIdTask
|
|
|
|
import com.google.firebase.crashlytics.buildtools.gradle.tasks.UploadMappingFileTask
|
|
|
|
import com.google.gms.googleservices.GoogleServicesTask
|
2024-05-29 18:36:35 +03:00
|
|
|
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
|
2024-09-26 11:21:22 +03:00
|
|
|
import java.io.FileInputStream
|
|
|
|
import java.util.Properties
|
2024-01-03 01:31:45 +03:00
|
|
|
|
2023-08-23 00:03:42 +03:00
|
|
|
plugins {
|
|
|
|
alias(libs.plugins.android.application)
|
2024-01-05 19:20:53 +03:00
|
|
|
// Crashlytics is enabled for all builds initially but removed for FDroid builds in gradle and
|
|
|
|
// standardDebug builds in the merged manifest.
|
2024-01-03 01:31:45 +03:00
|
|
|
alias(libs.plugins.crashlytics)
|
2023-08-23 00:03:42 +03:00
|
|
|
alias(libs.plugins.detekt)
|
|
|
|
alias(libs.plugins.hilt)
|
|
|
|
alias(libs.plugins.kotlin.android)
|
2024-05-29 18:36:35 +03:00
|
|
|
alias(libs.plugins.kotlin.compose.compiler)
|
2023-09-05 23:44:50 +03:00
|
|
|
alias(libs.plugins.kotlin.parcelize)
|
2023-08-23 00:03:42 +03:00
|
|
|
alias(libs.plugins.kotlin.serialization)
|
2023-10-16 18:12:39 +03:00
|
|
|
alias(libs.plugins.kotlinx.kover)
|
2023-08-23 00:03:42 +03:00
|
|
|
alias(libs.plugins.ksp)
|
2024-01-03 01:31:45 +03:00
|
|
|
alias(libs.plugins.google.services)
|
2024-06-20 23:44:39 +03:00
|
|
|
alias(libs.plugins.sonarqube)
|
2023-08-23 00:03:42 +03:00
|
|
|
}
|
|
|
|
|
2024-09-26 11:21:22 +03:00
|
|
|
/**
|
|
|
|
* Loads local user-specific build properties that are not checked into source control.
|
|
|
|
*/
|
|
|
|
val userProperties = Properties().apply {
|
|
|
|
val buildPropertiesFile = File(rootDir, "user.properties")
|
|
|
|
if (buildPropertiesFile.exists()) {
|
|
|
|
FileInputStream(buildPropertiesFile).use { load(it) }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-08-23 00:03:42 +03:00
|
|
|
android {
|
|
|
|
namespace = "com.x8bit.bitwarden"
|
|
|
|
compileSdk = libs.versions.compileSdk.get().toInt()
|
|
|
|
|
|
|
|
defaultConfig {
|
|
|
|
applicationId = "com.x8bit.bitwarden"
|
|
|
|
minSdk = libs.versions.minSdk.get().toInt()
|
|
|
|
targetSdk = libs.versions.targetSdk.get().toInt()
|
|
|
|
versionCode = 1
|
2024-09-19 16:15:15 +03:00
|
|
|
versionName = "2024.9.0"
|
2023-08-23 00:03:42 +03:00
|
|
|
|
2024-05-09 06:27:16 +03:00
|
|
|
setProperty("archivesBaseName", "com.x8bit.bitwarden")
|
|
|
|
|
2024-02-07 20:38:13 +03:00
|
|
|
ksp {
|
|
|
|
// The location in which the generated Room Database Schemas will be stored in the repo.
|
|
|
|
arg("room.schemaLocation", "$projectDir/schemas")
|
|
|
|
}
|
|
|
|
|
2023-08-23 00:03:42 +03:00
|
|
|
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
|
|
|
}
|
|
|
|
|
2024-02-12 23:06:21 +03:00
|
|
|
androidResources {
|
|
|
|
@Suppress("UnstableApiUsage")
|
|
|
|
generateLocaleConfig = true
|
|
|
|
}
|
|
|
|
|
2023-09-19 21:17:29 +03:00
|
|
|
signingConfigs {
|
|
|
|
getByName("debug") {
|
|
|
|
keyAlias = "androiddebugkey"
|
|
|
|
keyPassword = "android"
|
|
|
|
storeFile = file("../keystores/debug.keystore")
|
|
|
|
storePassword = "android"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-08-23 00:03:42 +03:00
|
|
|
buildTypes {
|
2023-09-06 19:38:04 +03:00
|
|
|
debug {
|
|
|
|
applicationIdSuffix = ".dev"
|
2023-09-19 21:17:29 +03:00
|
|
|
signingConfig = signingConfigs.getByName("debug")
|
2023-09-06 19:38:04 +03:00
|
|
|
isDebuggable = true
|
2023-08-23 00:03:42 +03:00
|
|
|
isMinifyEnabled = false
|
2024-08-29 21:07:21 +03:00
|
|
|
|
|
|
|
buildConfigField(type = "boolean", name = "HAS_DEBUG_MENU", value = "true")
|
2024-10-22 20:37:03 +03:00
|
|
|
buildConfigField(type = "boolean", name = "HAS_LOGS_ENABLED", value = "true")
|
2023-09-06 19:38:04 +03:00
|
|
|
}
|
2024-05-09 06:27:16 +03:00
|
|
|
|
|
|
|
// Beta and Release variants are identical except beta has a different package name
|
|
|
|
create("beta") {
|
|
|
|
applicationIdSuffix = ".beta"
|
2024-08-01 01:19:52 +03:00
|
|
|
isDebuggable = false
|
|
|
|
isMinifyEnabled = true
|
|
|
|
proguardFiles(
|
|
|
|
getDefaultProguardFile("proguard-android-optimize.txt"),
|
|
|
|
"proguard-rules.pro"
|
|
|
|
)
|
2024-08-29 21:07:21 +03:00
|
|
|
|
|
|
|
buildConfigField(type = "boolean", name = "HAS_DEBUG_MENU", value = "false")
|
2024-10-22 20:37:03 +03:00
|
|
|
buildConfigField(type = "boolean", name = "HAS_LOGS_ENABLED", value = "false")
|
2024-05-09 06:27:16 +03:00
|
|
|
}
|
2023-09-06 19:38:04 +03:00
|
|
|
release {
|
|
|
|
isDebuggable = false
|
|
|
|
isMinifyEnabled = true
|
2023-08-23 00:03:42 +03:00
|
|
|
proguardFiles(
|
|
|
|
getDefaultProguardFile("proguard-android-optimize.txt"),
|
|
|
|
"proguard-rules.pro"
|
|
|
|
)
|
2024-08-29 21:07:21 +03:00
|
|
|
|
|
|
|
buildConfigField(type = "boolean", name = "HAS_DEBUG_MENU", value = "false")
|
2024-10-22 20:37:03 +03:00
|
|
|
buildConfigField(type = "boolean", name = "HAS_LOGS_ENABLED", value = "false")
|
2023-08-23 00:03:42 +03:00
|
|
|
}
|
|
|
|
}
|
2023-12-28 22:10:30 +03:00
|
|
|
|
|
|
|
flavorDimensions += listOf("mode")
|
|
|
|
productFlavors {
|
|
|
|
create("standard") {
|
2023-12-29 00:09:04 +03:00
|
|
|
isDefault = true
|
2023-12-28 22:10:30 +03:00
|
|
|
dimension = "mode"
|
|
|
|
}
|
|
|
|
create("fdroid") {
|
|
|
|
dimension = "mode"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-08-23 00:03:42 +03:00
|
|
|
compileOptions {
|
|
|
|
sourceCompatibility(libs.versions.jvmTarget.get())
|
|
|
|
targetCompatibility(libs.versions.jvmTarget.get())
|
|
|
|
}
|
|
|
|
buildFeatures {
|
2023-10-30 23:47:54 +03:00
|
|
|
buildConfig = true
|
2023-08-23 00:03:42 +03:00
|
|
|
compose = true
|
|
|
|
}
|
|
|
|
packaging {
|
|
|
|
resources {
|
|
|
|
excludes += "/META-INF/{AL2.0,LGPL2.1}"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@Suppress("UnstableApiUsage")
|
|
|
|
testOptions {
|
|
|
|
// Required for Robolectric
|
|
|
|
unitTests.isIncludeAndroidResources = true
|
|
|
|
unitTests.isReturnDefaultValues = true
|
|
|
|
}
|
2024-06-27 17:38:19 +03:00
|
|
|
lint {
|
2024-10-28 20:47:27 +03:00
|
|
|
disable += listOf(
|
|
|
|
"MissingTranslation",
|
|
|
|
"ExtraTranslation",
|
|
|
|
)
|
2024-06-27 17:38:19 +03:00
|
|
|
}
|
2023-08-23 00:03:42 +03:00
|
|
|
}
|
|
|
|
|
2024-05-29 18:36:35 +03:00
|
|
|
kotlin {
|
|
|
|
compilerOptions {
|
|
|
|
jvmTarget.set(JvmTarget.fromTarget(libs.versions.jvmTarget.get()))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-09-26 11:21:22 +03:00
|
|
|
configurations.all {
|
|
|
|
resolutionStrategy.dependencySubstitution {
|
|
|
|
if ((userProperties["localSdk"] as String?).toBoolean()) {
|
|
|
|
substitute(module("com.bitwarden:sdk-android"))
|
|
|
|
.using(module("com.bitwarden:sdk-android:LOCAL"))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-08-23 00:03:42 +03:00
|
|
|
dependencies {
|
2024-01-03 01:31:45 +03:00
|
|
|
fun standardImplementation(dependencyNotation: Any) {
|
|
|
|
add("standardImplementation", dependencyNotation)
|
|
|
|
}
|
|
|
|
|
2024-11-04 17:24:36 +03:00
|
|
|
implementation(files("libs/authenticatorbridge-1.0.0-release.aar"))
|
2024-09-09 23:36:34 +03:00
|
|
|
|
2023-08-23 00:03:42 +03:00
|
|
|
implementation(libs.androidx.activity.compose)
|
2024-01-13 00:43:18 +03:00
|
|
|
implementation(libs.androidx.appcompat)
|
2024-01-16 07:37:50 +03:00
|
|
|
implementation(libs.androidx.autofill)
|
2023-10-11 18:37:03 +03:00
|
|
|
implementation(libs.androidx.browser)
|
2024-01-26 02:56:19 +03:00
|
|
|
implementation(libs.androidx.biometrics)
|
2024-01-03 02:29:48 +03:00
|
|
|
implementation(libs.androidx.camera.camera2)
|
|
|
|
implementation(libs.androidx.camera.lifecycle)
|
|
|
|
implementation(libs.androidx.camera.view)
|
2023-08-23 00:03:42 +03:00
|
|
|
implementation(platform(libs.androidx.compose.bom))
|
|
|
|
implementation(libs.androidx.compose.animation)
|
|
|
|
implementation(libs.androidx.compose.material3)
|
|
|
|
implementation(libs.androidx.compose.runtime)
|
|
|
|
implementation(libs.androidx.compose.ui)
|
|
|
|
implementation(libs.androidx.compose.ui.graphics)
|
|
|
|
implementation(libs.androidx.compose.ui.tooling.preview)
|
|
|
|
implementation(libs.androidx.core.ktx)
|
|
|
|
implementation(libs.androidx.hilt.navigation.compose)
|
2024-01-13 20:15:06 +03:00
|
|
|
implementation(libs.androidx.lifecycle.process)
|
2023-08-25 16:54:18 +03:00
|
|
|
implementation(libs.androidx.lifecycle.runtime.compose)
|
2023-08-23 00:03:42 +03:00
|
|
|
implementation(libs.androidx.lifecycle.runtime.ktx)
|
|
|
|
implementation(libs.androidx.navigation.compose)
|
|
|
|
ksp(libs.androidx.room.compiler)
|
|
|
|
implementation(libs.androidx.room.ktx)
|
|
|
|
implementation(libs.androidx.room.runtime)
|
2024-01-09 06:52:26 +03:00
|
|
|
implementation(libs.androidx.security.crypto)
|
2023-09-28 22:18:03 +03:00
|
|
|
implementation(libs.androidx.splashscreen)
|
2024-01-31 20:15:48 +03:00
|
|
|
implementation(libs.androidx.work.runtime.ktx)
|
2023-09-15 00:27:34 +03:00
|
|
|
implementation(libs.bitwarden.sdk)
|
2023-08-23 00:03:42 +03:00
|
|
|
implementation(libs.bumptech.glide)
|
2024-05-20 19:01:35 +03:00
|
|
|
implementation(libs.androidx.credentials)
|
2023-08-23 00:03:42 +03:00
|
|
|
implementation(libs.google.hilt.android)
|
2024-02-01 23:38:39 +03:00
|
|
|
ksp(libs.google.hilt.compiler)
|
2023-11-08 18:20:42 +03:00
|
|
|
implementation(libs.kotlinx.collections.immutable)
|
2023-08-23 00:03:42 +03:00
|
|
|
implementation(libs.kotlinx.coroutines.android)
|
|
|
|
implementation(libs.kotlinx.serialization)
|
|
|
|
implementation(libs.nulab.zxcvbn4j)
|
|
|
|
implementation(libs.square.okhttp)
|
|
|
|
implementation(libs.square.okhttp.logging)
|
2024-03-29 22:40:03 +03:00
|
|
|
implementation(platform(libs.square.retrofit.bom))
|
2023-08-23 00:03:42 +03:00
|
|
|
implementation(libs.square.retrofit)
|
2024-03-29 22:40:03 +03:00
|
|
|
implementation(libs.square.retrofit.kotlinx.serialization)
|
2024-10-22 20:37:03 +03:00
|
|
|
implementation(libs.timber)
|
2023-08-23 00:03:42 +03:00
|
|
|
implementation(libs.zxing.zxing.core)
|
|
|
|
|
|
|
|
// For now we are restricted to running Compose tests for debug builds only
|
|
|
|
debugImplementation(libs.androidx.compose.ui.test.manifest)
|
|
|
|
debugImplementation(libs.androidx.compose.ui.tooling)
|
|
|
|
|
2024-01-03 01:31:45 +03:00
|
|
|
// Standard-specific flavor dependencies
|
|
|
|
standardImplementation(libs.google.firebase.cloud.messaging)
|
|
|
|
standardImplementation(platform(libs.google.firebase.bom))
|
|
|
|
standardImplementation(libs.google.firebase.crashlytics)
|
|
|
|
|
2023-08-23 00:03:42 +03:00
|
|
|
testImplementation(libs.androidx.compose.ui.test)
|
|
|
|
testImplementation(libs.google.hilt.android.testing)
|
|
|
|
testImplementation(libs.junit.junit5)
|
|
|
|
testImplementation(libs.junit.vintage)
|
|
|
|
testImplementation(libs.kotlinx.coroutines.test)
|
|
|
|
testImplementation(libs.mockk.mockk)
|
|
|
|
testImplementation(libs.robolectric.robolectric)
|
2023-08-25 16:54:47 +03:00
|
|
|
testImplementation(libs.square.okhttp.mockwebserver)
|
2023-08-23 00:03:42 +03:00
|
|
|
testImplementation(libs.square.turbine)
|
|
|
|
|
|
|
|
detektPlugins(libs.detekt.detekt.formatting)
|
|
|
|
detektPlugins(libs.detekt.detekt.rules)
|
|
|
|
}
|
|
|
|
|
|
|
|
detekt {
|
|
|
|
autoCorrect = true
|
|
|
|
config.from(files("$rootDir/detekt-config.yml"))
|
|
|
|
}
|
|
|
|
|
2023-10-16 18:12:39 +03:00
|
|
|
kover {
|
2024-05-29 00:44:47 +03:00
|
|
|
currentProject {
|
|
|
|
sources {
|
|
|
|
excludeJava = true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
reports {
|
|
|
|
filters {
|
|
|
|
excludes {
|
|
|
|
androidGeneratedClasses()
|
|
|
|
annotatedBy(
|
|
|
|
// Compose previews
|
|
|
|
"androidx.compose.ui.tooling.preview.Preview",
|
2024-09-11 00:07:32 +03:00
|
|
|
"androidx.compose.ui.tooling.preview.PreviewScreenSizes",
|
2024-05-29 00:44:47 +03:00
|
|
|
// Manually excluded classes/files/etc.
|
|
|
|
"com.x8bit.bitwarden.data.platform.annotation.OmitFromCoverage",
|
|
|
|
)
|
|
|
|
classes(
|
|
|
|
// Navigation helpers
|
|
|
|
"*.*NavigationKt*",
|
|
|
|
// Composable singletons
|
|
|
|
"*.*ComposableSingletons*",
|
|
|
|
// Generated classes related to interfaces with default values
|
|
|
|
"*.*DefaultImpls*",
|
|
|
|
// Databases
|
|
|
|
"*.database.*Database*",
|
|
|
|
"*.dao.*Dao*",
|
|
|
|
// Dagger Hilt
|
|
|
|
"dagger.hilt.*",
|
|
|
|
"hilt_aggregated_deps.*",
|
|
|
|
"*_Factory",
|
|
|
|
"*_Factory\$*",
|
|
|
|
"*_*Factory",
|
|
|
|
"*_*Factory\$*",
|
|
|
|
"*.Hilt_*",
|
|
|
|
"*_HiltModules",
|
|
|
|
"*_HiltModules\$*",
|
|
|
|
"*_Impl",
|
|
|
|
"*_Impl\$*",
|
|
|
|
"*_MembersInjector",
|
|
|
|
)
|
|
|
|
packages(
|
|
|
|
// Dependency injection
|
|
|
|
"*.di",
|
|
|
|
// Models
|
|
|
|
"*.model",
|
|
|
|
// Custom UI components
|
|
|
|
"com.x8bit.bitwarden.ui.platform.components",
|
|
|
|
// Theme-related code
|
|
|
|
"com.x8bit.bitwarden.ui.platform.theme",
|
|
|
|
)
|
|
|
|
}
|
2023-10-16 18:12:39 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-08-23 00:03:42 +03:00
|
|
|
tasks {
|
|
|
|
getByName("check") {
|
|
|
|
// Add detekt with type resolution to check
|
2024-07-16 16:56:23 +03:00
|
|
|
dependsOn("detekt")
|
2023-08-23 00:03:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
withType<io.gitlab.arturbosch.detekt.Detekt>().configureEach {
|
|
|
|
jvmTarget = libs.versions.jvmTarget.get()
|
|
|
|
}
|
|
|
|
withType<io.gitlab.arturbosch.detekt.DetektCreateBaselineTask>().configureEach {
|
|
|
|
jvmTarget = libs.versions.jvmTarget.get()
|
|
|
|
}
|
|
|
|
|
|
|
|
withType<Test> {
|
|
|
|
useJUnitPlatform()
|
2024-02-05 21:11:55 +03:00
|
|
|
maxHeapSize = "2g"
|
2024-01-25 19:54:56 +03:00
|
|
|
maxParallelForks = Runtime.getRuntime().availableProcessors()
|
2024-02-05 21:11:55 +03:00
|
|
|
jvmArgs = jvmArgs.orEmpty() + "-XX:+UseParallelGC"
|
2023-08-23 00:03:42 +03:00
|
|
|
}
|
|
|
|
}
|
2024-01-03 01:31:45 +03:00
|
|
|
|
|
|
|
afterEvaluate {
|
|
|
|
// Disable Fdroid-specific tasks that we want to exclude
|
|
|
|
val tasks = tasks.withType<GoogleServicesTask>() +
|
|
|
|
tasks.withType<InjectMappingFileIdTask>() +
|
|
|
|
tasks.withType<UploadMappingFileTask>()
|
|
|
|
tasks
|
|
|
|
.filter { it.name.contains("Fdroid") }
|
|
|
|
.forEach { it.enabled = false }
|
|
|
|
}
|
2024-06-20 23:44:39 +03:00
|
|
|
|
|
|
|
sonar {
|
|
|
|
properties {
|
|
|
|
property("sonar.projectKey", "bitwarden_android")
|
|
|
|
property("sonar.organization", "bitwarden")
|
|
|
|
property("sonar.host.url", "https://sonarcloud.io")
|
2024-06-24 21:20:06 +03:00
|
|
|
property("sonar.sources", "app/src/")
|
|
|
|
property("sonar.tests", "app/src/")
|
|
|
|
property("sonar.test.inclusions", "app/src/test/")
|
2024-07-12 23:43:36 +03:00
|
|
|
property("sonar.exclusions", "app/src/test/")
|
2024-06-20 23:44:39 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
tasks {
|
|
|
|
getByName("sonar") {
|
|
|
|
dependsOn("check")
|
|
|
|
}
|
2024-09-26 11:21:22 +03:00
|
|
|
}
|