mirror of
https://github.com/ankidroid/Anki-Android.git
synced 2024-09-20 03:52:15 +02:00
6ff8871885
* build(deps): bump commons-io:commons-io from 2.15.0 to 2.15.1 Bumps commons-io:commons-io from 2.15.0 to 2.15.1. --- updated-dependencies: - dependency-name: commons-io:commons-io dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> * build(deps): bump androidx.webkit:webkit from 1.8.0 to 1.9.0 Bumps androidx.webkit:webkit from 1.8.0 to 1.9.0. --- updated-dependencies: - dependency-name: androidx.webkit:webkit dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * Update Gradle Wrapper from 8.4 to 8.5. Signed-off-by: gradle-update-robot <gradle-update-robot@regolo.cc> * build(deps): remove JDK18, support JDK21 (LTS) * build(deps): adopt jacoco 0.8.11 - supports JDK21 * style(lint): use new build variant configuration style documentation: https://developer.android.com/build/build-variants - defer configuration of build types / flavors with create/named, used in example - flavorDimensions is now a property so you += custom dimensions to it * style(lint): gradle .all --> .configureEach * style(lint): use imports vs fully qualified names * docs(gradle): update comment describing CI vCPU determination * style(lint): use deferred-configuration-compatible task registration/dependency * style(lint): deprecated kotlinOptions -> current compilerOptions * style(lint): project.buildDir -> project.layout.buildDirectory required a slightly different way of building the file tree for kotlin class location as input to the report, but despite being a little subtle it is not at all hard to understand --------- Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: gradle-update-robot <gradle-update-robot@regolo.cc> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: gradle-update-robot <gradle-update-robot@regolo.cc>
170 lines
4.8 KiB
Groovy
170 lines
4.8 KiB
Groovy
import groovy.transform.Memoized
|
|
|
|
apply plugin: 'jacoco'
|
|
|
|
jacoco {
|
|
toolVersion = "0.8.11"
|
|
|
|
}
|
|
|
|
android {
|
|
testCoverage {
|
|
jacocoVersion '0.8.11'
|
|
}
|
|
}
|
|
|
|
@Memoized
|
|
Properties getLocalProperties() {
|
|
final propertiesFile = project.rootProject.file("local.properties")
|
|
|
|
final properties = new Properties()
|
|
|
|
if (propertiesFile.exists()) {
|
|
properties.load(propertiesFile.newDataInputStream())
|
|
}
|
|
|
|
return properties
|
|
}
|
|
|
|
def openReport(htmlOutDir) {
|
|
final reportPath = "$htmlOutDir/index.html"
|
|
|
|
println "HTML Report: $reportPath"
|
|
|
|
if (!project.hasProperty("open-report")) {
|
|
println "to open the report automatically in your default browser add '-Popen-report' cli argument"
|
|
return
|
|
}
|
|
|
|
def os = org.gradle.internal.os.OperatingSystem.current()
|
|
if (os.isWindows()) {
|
|
exec { commandLine 'cmd', '/c', "start $reportPath" }
|
|
} else if (os.isMacOsX()) {
|
|
exec { commandLine 'open', "$reportPath" }
|
|
} else if (os.isLinux()) {
|
|
try {
|
|
exec { commandLine 'xdg-open', "$reportPath" }
|
|
} catch (Exception ignored) {
|
|
if (localProperties.containsKey("linux-html-cmd")) {
|
|
exec { commandLine properties.get("linux-html-cmd"), "$reportPath" }
|
|
} else {
|
|
println "'linux-html-cmd' property could not be found in 'local.properties'"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
tasks.withType(Test).configureEach {
|
|
jacoco.includeNoLocationClasses = true
|
|
jacoco.excludes = ['jdk.internal.*']
|
|
}
|
|
|
|
// source: https://medium.com/jamf-engineering/android-kotlin-code-coverage-with-jacoco-sonar-and-gradle-plugin-6-x-3933ed503a6e
|
|
def fileFilter = [
|
|
// 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$*.*'
|
|
]
|
|
|
|
// Our merge report task
|
|
def testReport = tasks.register('jacocoTestReport', JacocoReport) {
|
|
def htmlOutDir = project.layout.buildDirectory.dir("reports/jacoco/$name/html").get().asFile
|
|
|
|
doLast {
|
|
openReport htmlOutDir
|
|
}
|
|
|
|
reports {
|
|
xml.required = true
|
|
html.destination htmlOutDir
|
|
}
|
|
|
|
def kotlinClasses = fileTree(dir: project.layout.buildDirectory.dir('tmp/kotlin-classes/playDebug'), excludes: fileFilter)
|
|
def mainSrc = "$project.projectDir/src/main/java"
|
|
|
|
sourceDirectories.from = files([mainSrc])
|
|
classDirectories.from = files([kotlinClasses])
|
|
executionData.from = fileTree(dir: project.layout.buildDirectory, includes: [
|
|
'**/*.exec',
|
|
'**/*.ec'
|
|
])
|
|
}
|
|
testReport.configure {
|
|
dependsOn('testPlayDebugUnitTest')
|
|
dependsOn('connectedPlayDebugAndroidTest')
|
|
}
|
|
|
|
// A unit-test only report task
|
|
def unitTestReport = tasks.register('jacocoUnitTestReport', JacocoReport) {
|
|
def htmlOutDir = layout.buildDirectory.dir("reports/jacoco/$name/html").get().asFile
|
|
|
|
doLast {
|
|
openReport htmlOutDir
|
|
}
|
|
|
|
reports {
|
|
xml.required = true
|
|
html.destination htmlOutDir
|
|
}
|
|
|
|
def kotlinClasses = fileTree(dir: project.layout.buildDirectory.dir('tmp/kotlin-classes/playDebug'), excludes: fileFilter)
|
|
def mainSrc = "$project.projectDir/src/main/java"
|
|
|
|
sourceDirectories.from = files([mainSrc])
|
|
classDirectories.from = files([kotlinClasses])
|
|
executionData.from = fileTree(dir: project.layout.buildDirectory, includes: [
|
|
'**/*.exec'
|
|
|
|
])
|
|
}
|
|
unitTestReport.configure { dependsOn('testPlayDebugUnitTest') }
|
|
|
|
// A connected android tests only report task
|
|
def androidTestReport = tasks.register('jacocoAndroidTestReport', JacocoReport) {
|
|
def htmlOutDir = layout.buildDirectory.dir("reports/jacoco/$name/html").get().asFile
|
|
|
|
doLast {
|
|
openReport htmlOutDir
|
|
}
|
|
|
|
reports {
|
|
xml.required = true
|
|
html.destination htmlOutDir
|
|
}
|
|
|
|
def kotlinClasses = fileTree(dir: project.layout.buildDirectory.dir('tmp/kotlin-classes/playDebug'), excludes: fileFilter)
|
|
def mainSrc = "$project.projectDir/src/main/java"
|
|
|
|
sourceDirectories.from = files([mainSrc])
|
|
classDirectories.from = files([kotlinClasses])
|
|
executionData.from = fileTree(dir: project.layout.buildDirectory, includes: [
|
|
'**/*.ec'
|
|
])
|
|
}
|
|
androidTestReport.configure { dependsOn('connectedPlayDebugAndroidTest') }
|