-
Bug
-
Resolution: Obsolete
-
Normal
-
None
-
None
-
None
-
None
When running `./mvnw verify -Dcoverage`, the jacoco report is generated at `coverage-report/target/site/jacoco-aggregate`:
The covered percentage is quite slow comparing it with what we got from Sonar report:
The problem is that the report from Jacoco in Maven is not excluding the generated classes.
Acceptance Criteria
- The Jacoco plugin is not excluding the generated sources from the openapi or the jsonschema plugins. In order to configure this, we need to generate the generated sources into a separated package including the name generated. For example, from:
<plugin>
<groupId>org.jsonschema2pojo</groupId>
<artifactId>jsonschema2pojo-maven-plugin</artifactId>
<configuration>
<targetPackage>com.redhat.swatch.contract.model</targetPackage>
<outputDirectory>${project.build.directory}/generated-sources/src/main/java</outputDirectory>
<includeAdditionalProperties>false</includeAdditionalProperties>
To:
<plugin>
<groupId>org.jsonschema2pojo</groupId>
<artifactId>jsonschema2pojo-maven-plugin</artifactId>
<configuration>
<targetPackage>com.redhat.swatch.contract.model.generated</targetPackage>
<outputDirectory>${project.build.directory}/generated-sources/src/main/java</outputDirectory>
<includeAdditionalProperties>false</includeAdditionalProperties>
And next, configure the plugin to exclude these packages:
<build> <plugins> <plugin> <groupId>org.jacoco</groupId> <artifactId>jacoco-maven-plugin</artifactId> <executions> <execution> <id>report</id> <phase>verify</phase> <goals> <goal>report-aggregate</goal> </goals> <configuration> <dataFileIncludes> <dataFileInclude>**/jacoco.exec</dataFileInclude> </dataFileIncludes> <outputDirectory>${project.reporting.outputDirectory}/jacoco-aggregate</outputDirectory> <excludes> <exclude>**/generated/**</exclude> <exclude>**/openapi/**</exclude> </excludes> </configuration> </execution> </executions> </plugin> </plugins> </build>
Note that the openapi Maven plugin already generates the API under the openapi package, so we can use it to exlude it from the jacoco report. But, we need to double check that all the modules are configured to append the openapi name in the package.
- Configure the Jacoco plugin to exclude the generated classes, so the report is similar to what we have in Sonar Main.
- depends on
-
SWATCH-3423 Migrate gradle to Maven: everything but sonar plugin
-
- Closed
-
- is depended on by
-
SWATCH-3425 Migrate sonar plugin
-
- Closed
-