Coding⏱️ 2 min read📅 2026-05-31

How to Fix: Maven Jacoco Configuration - Exclude classes/packages from report not working

Exclude specific classes or packages from Jacoco code coverage reports in a Maven multi-module project.

Quick Answer: Use the element with a wildcard to exclude specific classes or packages, for example: some.package.*

In Maven Jacoco configuration, the <exclude> element is used to exclude classes or packages from the code coverage report. However, if you are using a multi-module project and trying to exclude certain classes or packages that are present in only one of the modules, the <exclude> element may not work as expected.

🔍 Why This Happens

  • The <exclude> element only works when the class or package is present in the current module, but not in any of its sub-modules.

✅ Best Solutions to Fix It

Method 1: Use the <excludes> Element

  1. Step 1: Instead of using the <exclude> element, use the <excludes> element to specify the packages or classes that you want to exclude.

Method 2: Use the <configuration> Element and Specify the Exclude Pattern

  1. Step 1: In the <configuration> element, specify the exclude pattern using the format 'some.package.*' or 'some.package.subpackage.*'.

🎯 Final Words

By following these methods, you should be able to exclude classes or packages from your Maven Jacoco report correctly.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions