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
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