|
| 1 | +# Multi-Project Builds |
| 2 | + |
| 3 | +For the aggregated multi-project build shown below: |
| 4 | + |
| 5 | +```scala |
| 6 | +lazy val common = project |
| 7 | + .in(file("common")) |
| 8 | + |
| 9 | +lazy val extras = project |
| 10 | + .in(file("extras")) |
| 11 | + |
| 12 | +lazy val root = project |
| 13 | + .in(file(".")) |
| 14 | + .aggregate( |
| 15 | + common, |
| 16 | + extras |
| 17 | + ) |
| 18 | +``` |
| 19 | + |
| 20 | +Running `sbt jacocoAggregate` will run the unit tests for each sub-project with coverage and then aggregate the |
| 21 | +individual reports into a single report in the root project: |
| 22 | + |
| 23 | +``` |
| 24 | +[info] ------- Jacoco Coverage Report ------- |
| 25 | +[info] |
| 26 | +[info] Lines: 100% (>= required 0.0%) covered, 0 of 3 missed, OK |
| 27 | +[info] Instructions: 100% (>= required 0.0%) covered, 0 of 29 missed, OK |
| 28 | +[info] Branches: 0% (>= required 0.0%) covered, 0 of 0 missed, OK |
| 29 | +[info] Methods: 100% (>= required 0.0%) covered, 0 of 2 missed, OK |
| 30 | +[info] Complexity: 100% (>= required 0.0%) covered, 0 of 2 missed, OK |
| 31 | +[info] Class: 100% (>= required 0.0%) covered, 0 of 1 missed, OK |
| 32 | +[info] |
| 33 | +[info] Check /home/example/jacoco-test/common/target/scala-2.12/jacoco/report for detailed report |
| 34 | +... |
| 35 | +[info] ------- Jacoco Coverage Report ------- |
| 36 | +[info] |
| 37 | +[info] Lines: 100% (>= required 0.0%) covered, 0 of 1 missed, OK |
| 38 | +[info] Instructions: 68.75% (>= required 0.0%) covered, 5 of 16 missed, OK |
| 39 | +[info] Branches: 0% (>= required 0.0%) covered, 0 of 0 missed, OK |
| 40 | +[info] Methods: 50% (>= required 0.0%) covered, 1 of 2 missed, OK |
| 41 | +[info] Complexity: 50% (>= required 0.0%) covered, 1 of 2 missed, OK |
| 42 | +[info] Class: 50% (>= required 0.0%) covered, 1 of 2 missed, OK |
| 43 | +[info] |
| 44 | +[info] Check /home/example/jacoco-test/extras/target/scala-2.12/jacoco/report for detailed report |
| 45 | +... |
| 46 | +[info] ------- Jacoco Aggregate Coverage Report ------- |
| 47 | +[info] |
| 48 | +[info] Lines: 100% (>= required 0.0%) covered, 0 of 4 missed, OK |
| 49 | +[info] Instructions: 88.89% (>= required 0.0%) covered, 5 of 45 missed, OK |
| 50 | +[info] Branches: 0% (>= required 0.0%) covered, 0 of 0 missed, OK |
| 51 | +[info] Methods: 75% (>= required 0.0%) covered, 1 of 4 missed, OK |
| 52 | +[info] Complexity: 75% (>= required 0.0%) covered, 1 of 4 missed, OK |
| 53 | +[info] Class: 66.67% (>= required 0.0%) covered, 1 of 3 missed, OK |
| 54 | +[info] |
| 55 | +[info] Check /home/example/jacoco-test/target/scala-2.12/jacoco/report/aggregate for detailed report |
| 56 | +``` |
| 57 | + |
| 58 | +@@@ note |
| 59 | +Due to a limitation in the way that the aggregate report is generated, there no line-by-line source reports are |
| 60 | +generated in the aggregate coverage report. These reports can be viewed by opening the sub-project reports. |
| 61 | +@@@ |
| 62 | + |
| 63 | +## Customising the Aggregate Report |
| 64 | + |
| 65 | +The aggregate report can be customised using the `jacocoAggregateReportSettings` key in the root project: |
| 66 | + |
| 67 | +```scala |
| 68 | +lazy val root = project |
| 69 | + .in(file(".")) |
| 70 | + .aggregate( |
| 71 | + common, |
| 72 | + extras |
| 73 | + ) |
| 74 | + .settings( |
| 75 | + jacocoAggregateReportSettings := JacocoReportSettings( |
| 76 | + title = "Foo Project Coverage", |
| 77 | + formats = Seq(JacocoReportFormats.ScalaHTML) |
| 78 | + ) |
| 79 | + ) |
| 80 | +``` |
0 commit comments