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
parent f762384277
commit a285141b1e
No known key found for this signature in database
GPG Key ID: 817AE1DD322D7ECA
2 changed files with 2 additions and 1 deletions

View File

@ -26,6 +26,7 @@ plugins {
id "de.undercouch.download" version "5.2.0" apply false id "de.undercouch.download" version "5.2.0" apply false
id "net.ltgt.errorprone" version "2.0.2" apply false id "net.ltgt.errorprone" version "2.0.2" apply false
id 'com.diffplug.spotless' version "6.5.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') apply from: file('gradle/globals.gradle')

View File

@ -26,7 +26,7 @@ if (withCoverage) {
allprojects { allprojects {
plugins.withType(JavaPlugin) { plugins.withType(JavaPlugin) {
// Apply jacoco once we know the project has a Java plugin too. // 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). // Synthetic task to enable test coverage (and reports).
task coverage() { task coverage() {