Reporting

About

The Reporting category in Maven involves plugins that generate various types of reports during the build process. These reports can include:

  • Test coverage

  • Code metrics

  • Static code analysis

  • Dependency and plugin usage

  • Project documentation summaries

These reports are useful for both developers and project stakeholders to assess code quality, test effectiveness, compliance, and maintainability.

Need for Reporting Plugins

  • Provide insight into codebase health (quality, complexity, bugs)

  • Enable auditable documentation of project state

  • Track test performance, coverage, and errors

  • Automatically document dependencies and plugin usage

  • Enhance transparency and maintainability across teams

maven-project-info-reports-plugin

Generates standard project documentation including dependencies, plugins, team info, SCM, licenses, and more.

Common Reports

Report
Description

dependencies

Shows all project dependencies

dependency-management

Shows dependencies managed via dependencyManagement

plugins

Lists build plugins

licenses

Details licenses used in the project

scm

Shows source code management info (like Git)

summary

High-level project info summary

Syntax

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-project-info-reports-plugin</artifactId>
  <version>3.4.5</version>
</plugin>

Usage

Runs with mvn site, or we can run individual goals like:

mvn project-info-reports:dependencies

maven-surefire-report-plugin

Generates HTML reports from test results produced by the Surefire plugin. Useful for viewing pass/fail details, error messages, and test case summaries.

Syntax

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-surefire-report-plugin</artifactId>
  <version>3.2.5</version>
</plugin>

Common Config Options

Property
Purpose

aggregate

Combine reports for multimodule projects

showSuccess

Show passed tests

outputName

Set custom name for report file

Usage

mvn surefire-report:report

This typically outputs surefire-report.html under target/site.

jacoco-maven-plugin

Generates code coverage reports for our tests. Helps us analyze which parts of the code are covered and which are not.

Syntax

<plugin>
  <groupId>org.jacoco</groupId>
  <artifactId>jacoco-maven-plugin</artifactId>
  <version>0.8.10</version>
  <executions>
    <execution>
      <id>prepare-agent</id>
      <goals><goal>prepare-agent</goal></goals>
    </execution>
    <execution>
      <id>report</id>
      <phase>verify</phase>
      <goals><goal>report</goal></goals>
    </execution>
  </executions>
</plugin>

Report Types

  • HTML

  • XML

  • CSV

Output

Reports go into target/site/jacoco/index.html

sonar-maven-plugin (SonarQube)

Integrates with SonarQube, a powerful code quality platform that analyzes:

  • Code smells

  • Bugs

  • Security vulnerabilities

  • Code coverage

  • Duplications

Syntax

<plugin>
  <groupId>org.sonarsource.scanner.maven</groupId>
  <artifactId>sonar-maven-plugin</artifactId>
  <version>3.9.1.2184</version>
</plugin>

Usage

Run with

mvn sonar:sonar \
  -Dsonar.projectKey=example \
  -Dsonar.host.url=http://localhost:9000 \
  -Dsonar.login=token

Requires a running SonarQube server and a configured token.

maven-site-plugin

This is the core plugin for generating a complete Maven site that includes all reporting, documentation, and static HTML pages for our project.

Syntax

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-site-plugin</artifactId>
  <version>4.0.0-M9</version>
</plugin>

Command to Generate Site

mvn site

It will include reports from all reporting plugins into the target/site/ directory in a browsable form.

Last updated

Was this helpful?