Maven Clirr plugin example: maven3 plugins tutorials
This tutorial covers Clirr Maven Plugin, configure and generate report tutorial with examples.
Maven Clirr plugin is used to report on your current project by comparing it with another same old project. If we configured this plugin to your project, it checks your project jar with an older version jar that is configured in pom.xml to compare. This plugin is to compare the source code as well as jar comparisons for incompatible issues to find in the early stage of any module before releasing the module.
Why maven clirr is important before maven release
If you are releasing any maven module, that module should be well worked with backward compatible with modules that use it. Once the module is released. that module is used by different developers of different teams, if you find any issues after release, then we have to fix that issue rereleasing is a tedious task. To avoid this, It is always a good idea to use clirr plugin execution checks against the previous version to verify compatibility before releasing any of your project modules. This will specify any binary compatibility issues with the previous code.
Adding this plugin is straightforward in pom.xml. we have to add this plugin element in the pluginManagement section of your project’s pom.xml. This is the same process for any new plugin to add to your project.
<pluginmanagement>
<plugins>
<plugin>
<groupid>org.codehaus.mojo</groupid>
<artifactid>clirr-maven-plugin</artifactid>
</plugin>
</plugins>
</pluginmanagement>
org.codehaus.mojo is providing the plugin to the maven repository. Once this plugin is configured, the clirr-maven-plugin is downloaded into your local repository.
Maven Clirr plugin reporting
Once you configured the clirr plugin, you have to generate the reports for the compatible issues. This report shows the list of all errors and warnings with detailed messages
<reporting>
<plugins>
<plugin>
<groupid>org.codehaus.mojo</groupid>
<artifactid>clirr-maven-plugin</artifactid>
<version>2.2.2</version>
<configuration>
<comparisonversion>1.1</comparisonversion>
</configuration>
</plugin>
</plugins>
</reporting>
if your current project version is 1.2, you need to check with the oldest project jar (1.1), then you have to define that version in a comparisonVersion element in the reporting section.
How to generate the Clirr report?
Once plugin configuration and reporting configuration is configured in pom.xml, we have to run the maven site command to generate the report.
maven site
By running this on the maven commands prompt, This will generate a clirr HTML report under the target/site folder with filename clirr-report.html
Alternatively, you can also run mvn clirr:clirr to generate the report.
mvn clirr:clirr
Hope you understand the basics of maven clirr plugin with examples.
Please feel to share your comments on this.