I had the same problem on Jacoco 0.8.8 (I guess they haven't fixed it yet). But I use maven, not gradle, so even though the accepted answer is correct, it was very hard for me to follow. First, files should be excluded in the report goal, not in the prepare-agent goal. That was not at all obvious to me and took careful reading of the maven jacoco help which can be seen using the following command
mvn help:describe -Dplugin=org.jacoco:jacoco-maven-plugin -Ddetail
Second, it wasn't obvious to me whether the exclude value was a path or a package reference and, if a path, what kind of path. By experimenting I found it's a path relative to the target/classes folder. Also note that foo/* excludes all the files in the foo folder. To exclude all files recursively under foo use foo/**/*. Based on all that this is what my unit test report goal looks like.
<!-- Use unit test coverage data to generate report -->
<execution>
<id>after-unit-tests-generate-report</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
<configuration>
<!-- Exclude alternate versions for multi-release modules-->
<excludes>
<exclude>META-INF/**/*</exclude>
</excludes>
<dataFile>${jacoco.data.file.ut}</dataFile>
<outputDirectory>${jacoco.report.folder.ut}</outputDirectory>
</configuration>
</execution>
That code excludes all the files under target/classes/META-INF. In other words, all the other versions besides the base. I was worried that my tests use Java 11 but my base is Java 8, but my coverage results seem correct.
Note the use of properties jacoco.data.file.ut and jacoco.report.folder.ut. Those are defined earlier in my pom file and otherwise are not relevant to this discussion. Also note, this is defined in the parent pom of a project with lots of child modules. Even though it is not inside a pluginManagement tag (only a plugins tag) it still applies for all the children.
exclusion
) the META-INF/*.class directory to start with? – Dannettedanni