Permalink
159 lines (142 sloc) 5.39 KB
/*
* Copyright (C) 2017 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
*
* http://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.
*/
apply plugin: 'com.android.application'
apply plugin: 'jacoco'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-allopen'
apply plugin: 'androidx.navigation.safeargs'
allOpen {
// allows mocking for classes w/o directly opening them for release builds
annotation 'com.android.example.github.testing.OpenClass'
}
android {
compileSdkVersion build_versions.target_sdk
buildToolsVersion build_versions.build_tools
defaultConfig {
applicationId "com.android.example.github"
minSdkVersion build_versions.min_sdk
targetSdkVersion build_versions.target_sdk
versionCode 1
versionName "1.0"
testInstrumentationRunner "com.android.example.github.util.GithubTestRunner"
}
buildTypes {
debug {
testCoverageEnabled !project.hasProperty('android.injected.invoked.from.ide')
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dataBinding {
enabled = true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
sourceSets {
androidTest.java.srcDirs += "src/test-common/java"
test.java.srcDirs += "src/test-common/java"
}
lintOptions {
lintConfig rootProject.file('lint.xml')
}
}
jacoco {
toolVersion = "0.7.4+"
}
dependencies {
implementation deps.support.app_compat
implementation deps.support.recyclerview
implementation deps.support.cardview
implementation deps.support.design
implementation deps.navigation.fragment_ktx
implementation deps.room.runtime
implementation deps.lifecycle.runtime
implementation deps.lifecycle.extensions
implementation deps.lifecycle.java8
implementation deps.retrofit.runtime
implementation deps.retrofit.gson
implementation deps.glide.runtime
implementation deps.dagger.runtime
implementation deps.dagger.android
implementation deps.dagger.android_support
implementation deps.constraint_layout
implementation deps.kotlin.stdlib
implementation deps.timber
kapt deps.dagger.android_support_compiler
kapt deps.dagger.compiler
kapt deps.room.compiler
kapt deps.lifecycle.compiler
testImplementation deps.junit
testImplementation deps.mock_web_server
testImplementation(deps.arch_core.testing, {
exclude group: 'com.android.support', module: 'support-compat'
exclude group: 'com.android.support', module: 'support-annotations'
exclude group: 'com.android.support', module: 'support-core-utils'
})
testImplementation deps.mockito.core
androidTestImplementation deps.navigation.testing_ktx
androidTestImplementation deps.support.app_compat
androidTestImplementation deps.support.recyclerview
androidTestImplementation deps.support.cardview
androidTestImplementation deps.support.design
androidTestImplementation(deps.espresso.core, {
exclude group: 'com.android.support', module: 'support-annotations'
exclude group: 'com.google.code.findbugs', module: 'jsr305'
})
androidTestImplementation(deps.espresso.contrib, {
exclude group: 'com.android.support', module: 'support-annotations'
exclude group: 'com.google.code.findbugs', module: 'jsr305'
})
androidTestImplementation(deps.arch_core.testing, {
})
androidTestImplementation deps.dexmaker
androidTestImplementation deps.mockito.core, { exclude group: 'net.bytebuddy' }
}
task fullCoverageReport(type: JacocoReport) {
dependsOn 'createDebugCoverageReport'
dependsOn 'testDebugUnitTest'
reports {
xml.enabled = true
html.enabled = true
}
def fileFilter = ['**/R.class', '**/R$*.class', '**/BuildConfig.*', '**/Manifest*.*',
'**/*Test*.*', 'android/**/*.*',
'**/*_MembersInjector.class',
'**/Dagger*Component.class',
'**/Dagger*Component$Builder.class',
'**/*_*Factory.class',
'**/*ComponentImpl.class',
'**/*SubComponentBuilder.class']
def debugTree = fileTree(dir: "${buildDir}/intermediates/classes/debug", excludes: fileFilter)
def mainSrc = "${project.projectDir}/src/main/java"
sourceDirectories = files([mainSrc])
classDirectories = files([debugTree])
executionData = fileTree(dir: "$buildDir", includes: [
"jacoco/testDebugUnitTest.exec",
"outputs/code-coverage/connected/*coverage.ec"
])
}
// we need all open to run tests which a we enable only for debug builds.
project.tasks.whenTaskAdded {
if (it.name == "testReleaseUnitTest") {
it.enabled = false
}
}