Add jacoco implementation

This commit is contained in:
Shinokuni 2021-09-16 22:29:25 +02:00
parent a3c3e7af1e
commit f4628b5a49
6 changed files with 69 additions and 4 deletions

2
.gitignore vendored
View File

@ -133,3 +133,5 @@ fastlane/Fastfile
Gemfile Gemfile
mapping/ mapping/
**/*.exec

View File

@ -28,6 +28,7 @@ android {
debug { debug {
minifyEnabled false minifyEnabled false
testCoverageEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
} }
} }

View File

@ -33,6 +33,7 @@ android {
minifyEnabled false minifyEnabled false
shrinkResources false shrinkResources false
testCoverageEnabled true
applicationIdSuffix ".debug" applicationIdSuffix ".debug"
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
} }

View File

@ -1,7 +1,7 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules. // Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript { buildscript {
ext.kotlin_version = '1.4.32' ext.kotlin_version = '1.5.30'
repositories { repositories {
google() google()
@ -10,10 +10,13 @@ buildscript {
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:4.2.2' classpath 'com.android.tools.build:gradle:4.2.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jacoco:org.jacoco.core:0.8.7"
} }
} }
allprojects { allprojects {
apply plugin: 'jacoco'
repositories { repositories {
google() google()
mavenCentral() mavenCentral()
@ -36,3 +39,53 @@ ext {
task clean(type: Delete) { task clean(type: Delete) {
delete rootProject.buildDir delete rootProject.buildDir
} }
jacoco {
toolVersion = "0.8.7"
}
task jacocoFullReport(type: JacocoReport) {
group = 'Reporting'
description = "Generate Jacoco coverage reports for the debug build"
reports {
html {
enabled true
destination file('build/reports/jacoco/html')
}
xml {
enabled true
destination file('build/reports/jacoco/jacocoFullReport.xml')
}
}
dependsOn ":app:testDebugUnitTest"
dependsOn ":api:testDebugUnitTest"
dependsOn ":db:testDebugUnitTest"
dependsOn ":app:connectedAndroidTest"
final fileFilter = ['**/R.class', '**/R$*.class', '**/BuildConfig.*', '**/Manifest*.*', 'android/**/*.*']
classDirectories.setFrom files([
fileTree(dir: "$project.rootDir/app/build/intermediates/javac/debug", excludes: fileFilter),
fileTree(dir: "$project.rootDir/app/build/tmp/kotlin-classes/debug", excludes: fileFilter),
fileTree(dir: "$project.rootDir/api/build/intermediates/javac/debug", excludes: fileFilter),
fileTree(dir: "$project.rootDir/api/build/tmp/kotlin-classes/debug", excludes: fileFilter),
fileTree(dir: "$project.rootDir/db/build/tmp/kotlin-classes/debug", excludes: fileFilter),
])
def coverageSourceDirs = [
"$project.rootDir/app/src/main/java",
"$project.rootDir/api/src/main/java",
"$project.rootDir/db/src/main/java",
]
additionalSourceDirs.setFrom files(coverageSourceDirs)
sourceDirectories.setFrom files(coverageSourceDirs)
executionData.setFrom fileTree(dir: project.rootDir, includes: [
'app/jacoco.exec',
'db/jacoco.exec',
'api/jacoco.exec',
'app/build/outputs/code_coverage/debugAndroidTest/connected/*-coverage.ec'
])
}

View File

@ -40,6 +40,7 @@ android {
debug { debug {
minifyEnabled false minifyEnabled false
testCoverageEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
} }
} }
@ -53,6 +54,14 @@ android {
} }
} }
// Needed for kapt starting with kotlin plugin 1.5
kapt {
arguments {
arg("room.schemaLocation", "$projectDir/schemas".toString())
arg("room.incremental", "true")
}
}
dependencies { dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar']) implementation fileTree(dir: 'libs', include: ['*.jar'])

View File

@ -12,7 +12,6 @@ org.gradle.jvmargs=-Xmx1536m
android.databinding.incremental=true android.databinding.incremental=true
kapt.incremental.apt=true kapt.incremental.apt=true
org.gradle.parallel=true org.gradle.parallel=true
kotlin.parallel.tasks.in.project=true
android.defaults.buildfeatures.buildconfig=false android.defaults.buildfeatures.buildconfig=false