-
Notifications
You must be signed in to change notification settings - Fork 319
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1e60d37b42af63f85dececfcb477653dcfaf2d14
- Loading branch information
Showing
29 changed files
with
739 additions
and
2,977 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,92 @@ | ||
// Need for the build form the Dash app with Gradle 8.1 | ||
if (VersionNumber.parse(project.getGradle().getGradleVersion()) < VersionNumber.parse("8.0")) { | ||
apply plugin: 'com.hiya.jacoco-android' | ||
apply plugin: 'jacoco' | ||
|
||
jacoco { | ||
toolVersion = "0.8.7" | ||
} | ||
|
||
tasks.withType(Test) { | ||
jacoco { | ||
toolVersion = "0.8.12" | ||
} | ||
|
||
// needed to capture coverage from Robolectric tests | ||
tasks.withType(Test) { | ||
jacoco.includeNoLocationClasses = true | ||
|
||
// required to run on Java 9+ | ||
// refs https://github.com/gradle/gradle/issues/5184#issuecomment-457865951 | ||
jacoco.excludes = ['jdk.internal.*'] | ||
} | ||
} | ||
|
||
static def excludes() { | ||
return [ | ||
// Android | ||
'**/R.class', | ||
'**/R$*.class', | ||
'**/BuildConfig.*', | ||
'**/Manifest*.*', | ||
// Android data binding | ||
'android/databinding/**/*.class', | ||
'**/android/databinding/*Binding.class', | ||
'**/BR.*' | ||
] | ||
} | ||
|
||
def findOrCreateJacocoTestReportTask() { | ||
Task jacocoTestReportTask = project.tasks.findByName("jacocoTestReport") | ||
if (!jacocoTestReportTask) { | ||
jacocoTestReportTask = project.tasks.create("jacocoTestReport") { | ||
group = "reporting" | ||
} | ||
} | ||
return jacocoTestReportTask | ||
} | ||
|
||
def createReportTask(variant) { | ||
def sourceDirs = variant.sourceSets.java.srcDirs.collect { it.path }.flatten() | ||
def classesDir = variant.hasProperty('javaCompileProvider') | ||
? variant.javaCompileProvider.get().destinationDir | ||
: variant.javaCompile.destinationDir | ||
def testTask = project.tasks.named("test${variant.name.capitalize()}UnitTest").get() | ||
def kotlin = project.plugins.findPlugin('kotlin-android') | ||
|
||
def reportTask = project.tasks.register("jacoco${testTask.name.capitalize()}Report", JacocoReport) { | ||
dependsOn(testTask) | ||
|
||
group = "reporting" | ||
description = "Generates Jacoco coverage reports for the ${variant.name} variant." | ||
executionData.setFrom(project.files(testTask.jacoco.destinationFile.path)) | ||
sourceDirectories.setFrom(project.files(sourceDirs)) | ||
|
||
FileTree javaTree = project.fileTree(dir: classesDir, excludes: excludes()) | ||
|
||
if (kotlin) { | ||
def kotlinClassesDir = project.layout.buildDirectory.dir("tmp/kotlin-classes/${variant.name}").get().asFile.path | ||
def kotlinTree = project.fileTree(dir: kotlinClassesDir, excludes: excludes()) | ||
classDirectories.setFrom(javaTree + kotlinTree) | ||
} else { | ||
classDirectories.setFrom(javaTree) | ||
} | ||
|
||
reports { | ||
xml.required = true | ||
csv.required = false | ||
html.required = true | ||
|
||
xml.outputLocation.set(project.layout.buildDirectory.file("jacoco/jacoco.xml").get()) | ||
csv.outputLocation.set(project.layout.buildDirectory.file("jacoco/jacoco.csv").get()) | ||
html.outputLocation.set(project.layout.buildDirectory.dir("jacoco/jacocoHtml").get()) | ||
} | ||
} | ||
|
||
return reportTask | ||
} | ||
|
||
private void logTaskAdded(JacocoReport reportTask) { | ||
logger.info("Added $reportTask") | ||
logger.info(" executionData: $reportTask.executionData.asPath") | ||
logger.info(" sourceDirectories: $reportTask.sourceDirectories.asPath") | ||
logger.info(" csv.outputLocation: ${reportTask.reports.csv.outputLocation.get()}") | ||
logger.info(" xml.outputLocation: ${reportTask.reports.xml.outputLocation.get()}") | ||
logger.info(" html.outputLocation: ${reportTask.reports.html.outputLocation.get()}") | ||
} | ||
|
||
project.android.libraryVariants.all { variant -> | ||
def jacocoTestReportTask = findOrCreateJacocoTestReportTask() | ||
|
||
def reportTask = createReportTask(variant) | ||
jacocoTestReportTask.dependsOn(reportTask) | ||
|
||
logTaskAdded(reportTask.get()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
tasks.configureEach { | ||
if (name == "packageDebugAssets" || name == "packageReleaseAssets" | ||
|| name == "mergeDebugAssets" || name == "mergeReleaseAssets") { | ||
def task = tasks.findByName("saveSDKVersion") | ||
if (task != null) { | ||
dependsOn task | ||
} | ||
} | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
#Thu Sep 01 12:16:51 MSK 2022 | ||
distributionBase=GRADLE_USER_HOME | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip | ||
distributionPath=wrapper/dists | ||
zipStorePath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-all.zip | ||
networkTimeout=10000 | ||
validateDistributionUrl=true | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
Oops, something went wrong.