mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 12:23:58 +01:00
Update file filters (#4640)
This commit is contained in:
parent
18b3e50c15
commit
457b03b7cb
1 changed files with 88 additions and 44 deletions
118
jacoco.gradle
118
jacoco.gradle
|
|
@ -4,58 +4,102 @@ jacoco {
|
||||||
toolVersion = "0.8.7"
|
toolVersion = "0.8.7"
|
||||||
}
|
}
|
||||||
|
|
||||||
android {
|
tasks.withType(Test) {
|
||||||
testOptions {
|
jacoco.includeNoLocationClasses = true
|
||||||
unitTests.all {
|
jacoco.excludes = ['jdk.internal.*']
|
||||||
jacoco {
|
// see related issue https://github.com/gradle/gradle/issues/5184#issuecomment-457865951
|
||||||
includeNoLocationClasses = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
project.afterEvaluate {
|
project.afterEvaluate {
|
||||||
|
|
||||||
android.applicationVariants.all { variant ->
|
(android.hasProperty('applicationVariants')
|
||||||
def name = variant.name
|
? android.'applicationVariants'
|
||||||
def testTaskName = "test${name.capitalize()}UnitTest"
|
: android.'libraryVariants')
|
||||||
|
.all { variant ->
|
||||||
|
def variantName = variant.name
|
||||||
|
def unitTestTask = "test${variantName.capitalize()}UnitTest"
|
||||||
|
|
||||||
tasks.create(name: "${testTaskName}Coverage", type: JacocoReport, dependsOn: "$testTaskName") {
|
tasks.create(name: "${unitTestTask}Coverage", type: JacocoReport, dependsOn: [
|
||||||
|
"$unitTestTask"
|
||||||
|
]) {
|
||||||
group = "Reporting"
|
group = "Reporting"
|
||||||
description = "Generate Jacoco coverage reports for the ${name.capitalize()} build."
|
description = "Generate Jacoco coverage reports for the ${variantName.capitalize()} build"
|
||||||
|
|
||||||
def fileFilter = ['**/R.class',
|
reports {
|
||||||
|
html.enabled = true
|
||||||
|
xml.enabled = true
|
||||||
|
}
|
||||||
|
|
||||||
|
def excludes = [
|
||||||
|
// data binding
|
||||||
|
'android/databinding/**/*.class',
|
||||||
|
'**/android/databinding/*Binding.class',
|
||||||
|
'**/android/databinding/*',
|
||||||
|
'**/androidx/databinding/*',
|
||||||
|
'**/BR.*',
|
||||||
|
// android
|
||||||
|
'**/R.class',
|
||||||
'**/R$*.class',
|
'**/R$*.class',
|
||||||
'**/*$ViewInjector*.*',
|
|
||||||
'**/*$ViewBinder*.*',
|
|
||||||
'**/BuildConfig.*',
|
'**/BuildConfig.*',
|
||||||
'**/Manifest*.*',
|
'**/Manifest*.*',
|
||||||
'**/*Test*.*',
|
'**/*Test*.*',
|
||||||
'android/**/*.*']
|
'android/**/*.*',
|
||||||
|
// butterKnife
|
||||||
|
'**/*$ViewInjector*.*',
|
||||||
|
'**/*$ViewBinder*.*',
|
||||||
|
'**/*ViewBinding*.*',
|
||||||
|
// dagger
|
||||||
|
'**/*_MembersInjector.class',
|
||||||
|
'**/Dagger*Component.class',
|
||||||
|
'**/Dagger*Component$Builder.class',
|
||||||
|
'**/*Module_*Factory.class',
|
||||||
|
'**/di/module/*',
|
||||||
|
'**/*_Factory*.*',
|
||||||
|
'**/*Module*.*',
|
||||||
|
'**/*Dagger*.*',
|
||||||
|
'**/*Hilt*.*',
|
||||||
|
// 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$*.*'
|
||||||
|
]
|
||||||
|
|
||||||
//java compiled classes
|
def javaClasses = fileTree(dir: variant.javaCompileProvider.get().destinationDir,
|
||||||
def javaTree = fileTree(
|
excludes: excludes)
|
||||||
dir: "${buildDir}/intermediates/classes/${name}",
|
def kotlinClasses = fileTree(dir: "${buildDir}/tmp/kotlin-classes/${variantName}",
|
||||||
excludes: fileFilter
|
excludes: excludes)
|
||||||
)
|
|
||||||
//kotlin compiled classes
|
|
||||||
def kotlinTree = fileTree(
|
|
||||||
dir: "${buildDir}/tmp/kotlin-classes/${name}",
|
|
||||||
excludes: fileFilter
|
|
||||||
)
|
|
||||||
def mainSrc = "${project.projectDir}/src/main/java"
|
|
||||||
|
|
||||||
sourceDirectories.setFrom(files([mainSrc]))
|
classDirectories.setFrom(files([
|
||||||
classDirectories.setFrom(files([javaTree, kotlinTree]))
|
javaClasses,
|
||||||
executionData.setFrom(fileTree(dir: "${buildDir}", includes: [
|
kotlinClasses
|
||||||
"jacoco/${testTaskName}.exec",
|
|
||||||
"outputs/code-coverage/connected/*coverage.ec"
|
|
||||||
]))
|
]))
|
||||||
|
|
||||||
reports {
|
def variantSourceSets = variant.sourceSets.java.srcDirs.collect { it.path }.flatten()
|
||||||
xml.enabled = true
|
sourceDirectories.setFrom(project.files(variantSourceSets))
|
||||||
html.enabled = true
|
|
||||||
}
|
executionData(files([
|
||||||
|
"$project.buildDir/jacoco/${unitTestTask}.exec"
|
||||||
|
]))
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue