|
|
|
/*
|
|
|
|
* Copyright 2021 The Android Open Source Project
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* https://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
plugins {
|
|
|
|
id 'com.android.application'
|
|
|
|
id 'kotlin-android'
|
|
|
|
id 'kotlin-kapt'
|
|
|
|
id 'kotlinx-serialization'
|
|
|
|
id 'jacoco'
|
|
|
|
id 'dagger.hilt.android.plugin'
|
|
|
|
alias(libs.plugins.protobuf)
|
|
|
|
alias(libs.plugins.ksp)
|
|
|
|
}
|
|
|
|
|
|
|
|
def jacocoTestReport = tasks.create("jacocoTestReport")
|
|
|
|
|
|
|
|
android {
|
|
|
|
compileSdk buildConfig.compileSdk
|
|
|
|
|
|
|
|
defaultConfig {
|
|
|
|
applicationId "com.google.samples.apps.nowinandroid"
|
|
|
|
minSdk buildConfig.minSdk
|
|
|
|
targetSdk buildConfig.targetSdk
|
|
|
|
versionCode 1
|
|
|
|
versionName "0.0.1" // X.Y.Z; X = Major, Y = minor, Z = Patch level
|
|
|
|
|
|
|
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
|
|
|
vectorDrawables {
|
|
|
|
useSupportLibrary true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
buildTypes {
|
|
|
|
release {
|
|
|
|
minifyEnabled true
|
|
|
|
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
compileOptions {
|
|
|
|
sourceCompatibility JavaVersion.VERSION_1_8
|
|
|
|
targetCompatibility JavaVersion.VERSION_1_8
|
|
|
|
coreLibraryDesugaringEnabled true
|
|
|
|
}
|
|
|
|
kotlinOptions {
|
|
|
|
jvmTarget = '1.8'
|
|
|
|
useIR = true
|
|
|
|
}
|
|
|
|
buildFeatures {
|
|
|
|
compose true
|
|
|
|
}
|
|
|
|
composeOptions {
|
|
|
|
kotlinCompilerExtensionVersion libs.versions.androidxCompose.get()
|
|
|
|
}
|
|
|
|
packagingOptions {
|
|
|
|
resources {
|
|
|
|
excludes += '/META-INF/{AL2.0,LGPL2.1}'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
testOptions {
|
|
|
|
unitTests {
|
|
|
|
includeAndroidResources = true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
androidComponents {
|
|
|
|
def coverageExclusions = [
|
|
|
|
// Android
|
|
|
|
"**/R.class",
|
|
|
|
"**/R\$*.class",
|
|
|
|
"**/BuildConfig.*",
|
|
|
|
"**/Manifest*.*"
|
|
|
|
]
|
|
|
|
|
|
|
|
onVariants(
|
|
|
|
selector().all(),
|
|
|
|
{ variant ->
|
|
|
|
def testTaskName = "test${variant.name.capitalize()}UnitTest"
|
|
|
|
|
|
|
|
def reportTask = tasks.register("jacoco${testTaskName.capitalize()}Report", JacocoReport) {
|
|
|
|
dependsOn(testTaskName)
|
|
|
|
|
|
|
|
reports {
|
|
|
|
xml.required.set(true)
|
|
|
|
html.required.set(true)
|
|
|
|
}
|
|
|
|
|
|
|
|
classDirectories.setFrom(
|
|
|
|
fileTree("$buildDir/tmp/kotlin-classes/${variant.name}") {
|
|
|
|
exclude(coverageExclusions)
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
sourceDirectories.setFrom(files("$projectDir/src/main/java", "$projectDir/src/main/kotlin"))
|
|
|
|
executionData.setFrom(file("$buildDir/jacoco/${testTaskName}.exec"))
|
|
|
|
}
|
|
|
|
|
|
|
|
jacocoTestReport.dependsOn(reportTask)
|
|
|
|
}
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Setup protobuf configuration, generating lite Java and Kotlin classes
|
|
|
|
protobuf {
|
|
|
|
protoc {
|
|
|
|
artifact = libs.protobuf.protoc.get()
|
|
|
|
}
|
|
|
|
generateProtoTasks {
|
|
|
|
all().each { task ->
|
|
|
|
task.builtins {
|
|
|
|
java {
|
|
|
|
option "lite"
|
|
|
|
}
|
|
|
|
kotlin {
|
|
|
|
option "lite"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
dependencies {
|
|
|
|
coreLibraryDesugaring libs.android.desugarJdkLibs
|
|
|
|
|
|
|
|
implementation libs.kotlinx.coroutines.android
|
|
|
|
implementation libs.kotlinx.datetime
|
|
|
|
implementation libs.kotlinx.serialization.json
|
|
|
|
|
|
|
|
implementation libs.androidx.activity.compose
|
|
|
|
implementation libs.androidx.core.ktx
|
|
|
|
implementation libs.androidx.dataStore
|
|
|
|
implementation libs.androidx.appcompat
|
|
|
|
implementation libs.androidx.hilt.navigation.compose
|
|
|
|
implementation libs.androidx.lifecycle.viewModelCompose
|
|
|
|
implementation libs.androidx.navigation.compose
|
|
|
|
implementation libs.material3
|
|
|
|
|
|
|
|
implementation libs.accompanist.flowlayout
|
|
|
|
implementation libs.accompanist.insets
|
|
|
|
|
|
|
|
implementation libs.androidx.compose.foundation.layout
|
|
|
|
// TODO (M3): Remove this dependency when all components are available
|
|
|
|
implementation libs.androidx.compose.material
|
|
|
|
implementation libs.androidx.compose.material.iconsExtended
|
|
|
|
implementation libs.androidx.compose.material3
|
|
|
|
implementation libs.androidx.compose.ui.tooling
|
|
|
|
implementation libs.androidx.compose.ui.util
|
|
|
|
implementation libs.androidx.compose.runtime
|
|
|
|
implementation libs.androidx.compose.runtime.livedata
|
|
|
|
|
|
|
|
implementation libs.hilt.android
|
|
|
|
kapt libs.hilt.compiler
|
|
|
|
|
|
|
|
implementation libs.room.runtime
|
|
|
|
ksp libs.room.compiler
|
|
|
|
|
|
|
|
implementation libs.protobuf.kotlin.lite
|
|
|
|
|
|
|
|
debugImplementation libs.androidx.compose.ui.testManifest
|
|
|
|
|
|
|
|
testImplementation libs.junit4
|
|
|
|
testImplementation libs.mockk
|
|
|
|
testImplementation libs.androidx.test.core
|
|
|
|
testImplementation libs.kotlinx.coroutines.test
|
|
|
|
testImplementation libs.turbine
|
|
|
|
|
|
|
|
androidTestImplementation libs.androidx.test.espresso.core
|
|
|
|
androidTestImplementation libs.androidx.test.runner
|
|
|
|
androidTestImplementation libs.androidx.test.rules
|
|
|
|
androidTestImplementation libs.androidx.compose.ui.test
|
|
|
|
|
|
|
|
// androidx.test is forcing JUnit, 4.12. This forces it to use 4.13
|
|
|
|
configurations.configureEach {
|
|
|
|
resolutionStrategy {
|
|
|
|
force libs.junit4
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
jacoco {
|
|
|
|
toolVersion libs.versions.jacoco.get()
|
|
|
|
}
|
|
|
|
|
|
|
|
tasks.withType(Test) {
|
|
|
|
jacoco {
|
|
|
|
// Required for JaCoCo + Robolectric
|
|
|
|
// https://github.com/robolectric/robolectric/issues/2230
|
|
|
|
// TODO: Consider removing if not we don't add Robolectric
|
|
|
|
setIncludeNoLocationClasses(true)
|
|
|
|
|
|
|
|
// Required for JDK 11+ with the above
|
|
|
|
// https://github.com/gradle/gradle/issues/5184#issuecomment-391982009
|
|
|
|
excludes = ["jdk.internal.*"]
|
|
|
|
}
|
|
|
|
}
|