mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 12:23:58 +01:00
* Fix jacoco setup * Fix task name * Update CI yml file for codecov * Fix syntax error * Use all branch instead of just master * Fix report upload issue * Remove returnDefaultValues * Add Github Action and Codecov badge
61 lines
No EOL
1.9 KiB
Groovy
61 lines
No EOL
1.9 KiB
Groovy
apply plugin: 'jacoco'
|
|
|
|
jacoco {
|
|
toolVersion = "0.8.7"
|
|
}
|
|
|
|
android {
|
|
testOptions {
|
|
unitTests.all {
|
|
jacoco {
|
|
includeNoLocationClasses = true
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
project.afterEvaluate {
|
|
|
|
android.applicationVariants.all { variant ->
|
|
def name = variant.name
|
|
def testTaskName = "test${name.capitalize()}UnitTest"
|
|
|
|
tasks.create(name: "${testTaskName}Coverage", type: JacocoReport, dependsOn: "$testTaskName") {
|
|
group = "Reporting"
|
|
description = "Generate Jacoco coverage reports for the ${name.capitalize()} build."
|
|
|
|
def fileFilter = ['**/R.class',
|
|
'**/R$*.class',
|
|
'**/*$ViewInjector*.*',
|
|
'**/*$ViewBinder*.*',
|
|
'**/BuildConfig.*',
|
|
'**/Manifest*.*',
|
|
'**/*Test*.*',
|
|
'android/**/*.*']
|
|
|
|
//java compiled classes
|
|
def javaTree = fileTree(
|
|
dir: "${buildDir}/intermediates/classes/${name}",
|
|
excludes: fileFilter
|
|
)
|
|
//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([javaTree, kotlinTree]))
|
|
executionData.setFrom(fileTree(dir: "${buildDir}", includes: [
|
|
"jacoco/${testTaskName}.exec",
|
|
"outputs/code-coverage/connected/*coverage.ec"
|
|
]))
|
|
|
|
reports {
|
|
xml.enabled = true
|
|
html.enabled = true
|
|
}
|
|
}
|
|
}
|
|
} |