[英]Exclude databinding package from jacoco report
In my jacoco report I see some weird databinding package.在我的 jacoco 报告中,我看到了一些奇怪的数据绑定包。
I tried adding following to my build.gradle to exclude it:我尝试将以下内容添加到我的 build.gradle 以排除它:
testOptions {
unitTests.all {
jacoco {
includeNoLocationClasses = true
afterEvaluate {
classDirectories.setFrom(files(classDirectories.files.collect {
fileTree(dir: it, exclude: '**/*databinding/**/*.*')
}))
}
classDirectories = fileTree(
dir: "${project.buildDir}",
excludes: ['**/*databinding/**/*.*']
)
}
}
}
It seems that they don't work.似乎它们不起作用。 Is there a way to remove this package/folder from my report?有没有办法从我的报告中删除这个包/文件夹?
you can define much extensive filefilter你可以定义更广泛的文件过滤器
def fileFilter = [
// data binding
'android/databinding/**/*.class',
'**/android/databinding/*Binding.class',
'**/android/databinding/*',
'**/androidx/databinding/*',
'**/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.*',
]
def javaTree = fileTree(dir: "${project.buildDir}/intermediates/javac/$sourceName/classes", excludes: fileFilter)
def kotlinTree = fileTree(dir: "${project.buildDir}/tmp/kotlin-classes/$sourceName", excludes: fileFilter)
classDirectories.from = files([javaTree], [kotlinTree])
reference - https://medium.com/nerd-for-tech/setup-jacoco-code-coverage-with-your-multimodule-android-app-kotlin-a0f82573a1参考 - https://medium.com/nerd-for-tech/setup-jacoco-code-coverage-with-your-multimodule-android-app-kotlin-a0f82573a1
Your exclusion is almost correct, here is the right one:您的排除几乎是正确的,这是正确的:
'**/databinding/*' '**/数据绑定/*'
This is because the databinding build files reside in这是因为数据绑定构建文件驻留在
app\\build\\intermediates\\javac\\[buildVariantName]\\classes\\[your\\package\\name]\\databinding app\\build\\intermediates\\javac\\[buildVariantName]\\classes\\[your\\package\\name]\\databinding
I can't seem to find the docs right now, but i think your exclusion databinding/**/*.*
is pointing to any file in a subdirectory of databinding and not to the files in the directory itself我现在似乎找不到文档,但我认为您的排除databinding/**/*.*
指向数据绑定子目录中的任何文件,而不是目录本身中的文件
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.