make 'gradle coverage' print test coverage summaries. (#11837)

Currently, this task is too silent and just writes HTML reports. It is a
nice improvement to print the summary to the console.

Before:

```
> Task :lucene:analysis:icu:jacocoTestReport
Code coverage report at: /home/rmuir/workspace/lucene/lucene/analysis/icu/build/reports/jacoco/test/html.
```

After:

```
> Task :lucene:analysis:icu:jacocoTestReport
Code coverage report at: /home/rmuir/workspace/lucene/lucene/analysis/icu/build/reports/jacoco/test/html.

> Task :lucene:analysis:icu:jacocoLogTestCoverage
Test Coverage:
    - Class Coverage: 100%
    - Method Coverage: 87.9%
    - Branch Coverage: 82.7%
    - Line Coverage: 92.8%
    - Instruction Coverage: 92.7%
    - Complexity Coverage: 78.8%
```
This commit is contained in:
Robert Muir 2022-10-05 21:46:20 -04:00 committed by GitHub
parent d966adcb62
commit 4c434b7089
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 2 deletions

View File

@ -26,6 +26,7 @@ plugins {
id "de.undercouch.download" version "5.2.0" apply false
id "net.ltgt.errorprone" version "2.0.2" apply false
id 'com.diffplug.spotless' version "6.5.2" apply false
id 'org.barfuin.gradle.jacocolog' version "2.0.0" apply false
}
apply from: file('gradle/globals.gradle')
@ -179,4 +180,4 @@ apply from: file('gradle/hacks/hashmapAssertions.gradle')
apply from: file('gradle/hacks/turbocharge-jvm-opts.gradle')
apply from: file('gradle/hacks/dummy-outputs.gradle')
apply from: file('gradle/pylucene/pylucene.gradle')
apply from: file('gradle/pylucene/pylucene.gradle')

View File

@ -26,7 +26,7 @@ if (withCoverage) {
allprojects {
plugins.withType(JavaPlugin) {
// Apply jacoco once we know the project has a Java plugin too.
project.plugins.apply("jacoco")
project.plugins.apply("org.barfuin.gradle.jacocolog")
// Synthetic task to enable test coverage (and reports).
task coverage() {