Issue#35 Jacoco works for Java modules and UnitTests.
- Not on AndroidTest (issue reported). - Not aggregated.
This commit is contained in:
parent
a5dcdd3409
commit
29083518f2
2 changed files with 91 additions and 0 deletions
|
|
@ -8,6 +8,7 @@ buildscript {
|
||||||
ext.compileSdkVersion = 32
|
ext.compileSdkVersion = 32
|
||||||
ext.minSdkVersion = 21
|
ext.minSdkVersion = 21
|
||||||
ext.targetSdkVersion = 32
|
ext.targetSdkVersion = 32
|
||||||
|
ext.jacoco_version = "0.8.8"
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
google()
|
google()
|
||||||
|
|
@ -20,6 +21,7 @@ buildscript {
|
||||||
classpath "com.google.dagger:hilt-android-gradle-plugin:$hilt_version"
|
classpath "com.google.dagger:hilt-android-gradle-plugin:$hilt_version"
|
||||||
classpath "org.jlleitschuh.gradle:ktlint-gradle:10.2.1"
|
classpath "org.jlleitschuh.gradle:ktlint-gradle:10.2.1"
|
||||||
classpath "io.gitlab.arturbosch.detekt:detekt-gradle-plugin:$detekt_version"
|
classpath "io.gitlab.arturbosch.detekt:detekt-gradle-plugin:$detekt_version"
|
||||||
|
classpath "org.jacoco:org.jacoco.core:$jacoco_version"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -50,3 +52,4 @@ apply from: 'gradlescripts/testoptions.gradle'
|
||||||
apply from: 'gradlescripts/test.tasks.gradle'
|
apply from: 'gradlescripts/test.tasks.gradle'
|
||||||
apply from: 'gradlescripts/testdependencies.gradle'
|
apply from: 'gradlescripts/testdependencies.gradle'
|
||||||
apply from: 'gradlescripts/disable.test.task.gradle'
|
apply from: 'gradlescripts/disable.test.task.gradle'
|
||||||
|
apply from: 'gradlescripts/jacoco.config.gradle'
|
||||||
|
|
|
||||||
88
gradlescripts/jacoco.config.gradle
Normal file
88
gradlescripts/jacoco.config.gradle
Normal file
|
|
@ -0,0 +1,88 @@
|
||||||
|
def androidFileFilter =
|
||||||
|
[ //jdk
|
||||||
|
'jdk.internal.*',
|
||||||
|
// data binding
|
||||||
|
'**/databinding/*.class',
|
||||||
|
'**/BR.*',
|
||||||
|
// android
|
||||||
|
'**/R.class',
|
||||||
|
'**/R$*.class',
|
||||||
|
'**/BuildConfig.*',
|
||||||
|
'**/Manifest*.*',
|
||||||
|
'**/*Test*.*',
|
||||||
|
'android/**/*.*',
|
||||||
|
// kotlin
|
||||||
|
'**/*MapperImpl*.*',
|
||||||
|
'**/*$ViewInjector*.*',
|
||||||
|
'**/*$ViewBinder*.*',
|
||||||
|
'**/BuildConfig.*',
|
||||||
|
'**/*Component*.*',
|
||||||
|
'**/*BR*.*',
|
||||||
|
'**/Manifest*.*',
|
||||||
|
'**/*$Lambda$*.*',
|
||||||
|
'**/*Companion*.*',
|
||||||
|
'**/*Module*.*',
|
||||||
|
'**/*Dagger*.*',
|
||||||
|
'**/*Hilt*.*',
|
||||||
|
'**/*MembersInjector*.*',
|
||||||
|
'**/*_MembersInjector.class',
|
||||||
|
'**/*_Factory*.*',
|
||||||
|
'**/*_Provide*Factory*.*',
|
||||||
|
'**/*Extensions*.*',
|
||||||
|
// sealed and data classes
|
||||||
|
'**/*$Result.*',
|
||||||
|
'**/*$Result$*.*',
|
||||||
|
// adapters generated by moshi
|
||||||
|
'**/*JsonAdapter.*',
|
||||||
|
// room
|
||||||
|
'**/*_Impl.class',
|
||||||
|
'**/*_Impl*.*',
|
||||||
|
]
|
||||||
|
|
||||||
|
subprojects { module ->
|
||||||
|
plugins.withType(JavaPlugin).whenPluginAdded {
|
||||||
|
configure(module) {
|
||||||
|
apply plugin: "jacoco"
|
||||||
|
|
||||||
|
jacocoTestReport {
|
||||||
|
dependsOn test // tests are required to run before generating the report
|
||||||
|
|
||||||
|
afterEvaluate {
|
||||||
|
classDirectories.setFrom(files(classDirectories.files.collect {
|
||||||
|
fileTree(dir: it, exclude: androidFileFilter)
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
plugins.withId("com.android.application") {
|
||||||
|
configure(module) {
|
||||||
|
apply plugin: "jacoco"
|
||||||
|
|
||||||
|
module.android.testOptions.unitTests.all {
|
||||||
|
jacoco.includeNoLocationClasses = true
|
||||||
|
jacoco.excludes = androidFileFilter
|
||||||
|
}
|
||||||
|
android.buildTypes.debug.enableAndroidTestCoverage true
|
||||||
|
android.buildTypes.debug.enableUnitTestCoverage true
|
||||||
|
|
||||||
|
jacoco.toolVersion = "$jacoco_version"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
plugins.withId("com.android.library") {
|
||||||
|
configure(module) {
|
||||||
|
apply plugin: "jacoco"
|
||||||
|
|
||||||
|
module.android.testOptions.unitTests.all {
|
||||||
|
jacoco.includeNoLocationClasses = true
|
||||||
|
jacoco.excludes = androidFileFilter
|
||||||
|
}
|
||||||
|
android.buildTypes.debug.enableAndroidTestCoverage true
|
||||||
|
android.buildTypes.debug.enableUnitTestCoverage true
|
||||||
|
|
||||||
|
jacoco.toolVersion = "$jacoco_version"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue