I understand I can exclude packages and classes with this configuration for example:
<configuration>
<excludes>
<exclude>**/*JavaProjectApi.class</exclude>
<exclude>com.sun.*</exclude>
</excludes>
</configuration>
However I encountered 2 issues while defining jacoco in multi maven module. I have one module that shows a very low coverage (0.002) although when I run jacoco in eclipse I get an higher result (50%+).
When I build this module I get in the target folder jacoco.exec generated and in the site/jacoco folder I see a lot of packages that are unrelated directly to this module. For example I see 50 folders of org.apache.olingo etc. which probably is the cause for reducing the overall coverage.
1) What causes them to be added in the first place?
I tries to exclude this package
<configuration>
<excludes>
<exclude>org.apache.olingo.*</exclude>
</excludes>
</configuration>
from several places but I still see these packages in the jacoco->site.
2) How exactly can ignore them so that they will not be added at all to the index.html report in jacoco/site and will not effect the coverage percentage?
I would be grateful for your help!
Thanks a lot in advance!
Vered
Thank you so much for your advice!
You were right! In the build process it copies additional classes so that it allows a local maven repository..
For one module I could remove this build part and succeed to see the report I wanted, but for the other module its essential to copy these classes..
Even if I added the following in the pom:
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<executions>
<execution>
<id>jacoco-report</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
<configuration>
<excludes>
<exclude>org/apache/olingo/*</exclude>
</excludes>
</configuration>
</execution>
</executions>
</plugin>
I saw org/apache/olingo folders generated in jacoco->site and in the report.
This is how this build section of this pom looks like..
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
<resource>
<directory>${project.build.directory}/unpackdependencies</directory>
<filtering>false</filtering>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>process-sources</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>com.some.group.id</groupId>
<artifactId>java-maven-repo-builder</artifactId>
<version>${project.version}</version>
<classifier>bin</classifier>
<type>zip</type>
<overWrite>false</overWrite>
<outputDirectory>${project.build.directory}/unpackdependencies</outputDirectory>
<destFileName>java-maven-repository.zip</destFileName>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<executions>
<execution>
<id>jacoco-report</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
<configuration>
<excludes>
<exclude>org/apache/olingo/*</exclude>
</excludes>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
Since it is part of the build nothing that I do to exclude these packages worked.
Do you have any suggestion in this case?
Thanks in advance!
Vered
I'm so grateful for your answer!!
I am the first to integrate Jacoco in our group repositories so I had no one to consult with. So your help is blessed!
I apologize for giving only snippet of the pom, I didn't want to give overload of information but of course you are right and this was necessary :)
Finally I excluded the zip file itself that was generated during build and it worked!
I don't use maven-site-plugin..I mention site just because it is the folder where I can see the generated report index.html and so to make sure the coverage is what I expected it to be (percentages, classes included/excluded...)
I suppose the index.html reports reflect the jacoco.exec files. The execs will be consumed by our SonarQube by configuring the paths to all the jacoco files. As of my understanding in this way they can be merge so that the final result will be a merged report.
Thank you again for all your help!
Best Regards,
Vered