Walter has been developing applications since the 80's, and professionally since the late 90's. He has been an early adopter of Java technology in the dot com days, and has managed and led software development teams across the globe. Walter has posted 4 posts at DZone. View Full User Profile

Trending Analysis With Maven Dashboard

06.17.2009
| 7770 views |
  • submit to reddit

Continuous integration is talked about as part of Agile development practices. It is lauded for its use to keep developers from “breaking the build”. This tip will discuss how to implement trend reporting in daily builds using the Maven and the Maven-dashboard plug-in. Continuous integration or CI that should be looked at beyond the scope of constantly compiling checked-in code. It is one step in many, which should be part of a code review process.

Maven project builds lends itself well in facilitating builds and generating artifacts such as reports on code quality. These report plug-ins can track levels of unit tests and code coverage, how well code is following coding practices via checkstyles, or suboptimal code or duplication of code.

In the ideal world of software development, these reports would be reviewed daily as part of a code review process. The truth be told it doesn't always occur. Software engineers and their leads are humans with time constraints. Chalk it up to having attend the next time management course. The next best solution is at least identify trends of which way the code is progressing. Maven dashboard provides historical trending.

The Maven dashboard plug-in can store report statistics in a database and generate site reports with trends from prior daily and weekly builds. Since reports take time it is best that they are run once a day during off peak development hours. That is because they take up additional cycles in the continuous build process, which could lead to delivery time problems. At a minimum, report type builds should be done on a nightly basis to get trending benefits. There are a number of steps to follow to show trends in a generated site.

For the purpose of this sample, it is assumed an installation of the latest version of Maven 2.0, and JDK 1.4 or later. The last requirement is a persistence storage. MySql will be a good storage base for the application history. A basic understanding of Maven 2.0 project structure is also necessary. Kepping with the simple idea this demonstrates only a single project set-up. Listing 1. is a basic maven project. For demonstration purpose, the project will includes TestNG dependency.


Listing 1. Pom.xml project

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.softlanding.dashboard</groupId>
<artifactId>example-dashboard</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>Example dashboard with maven</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>5.1</version>
<classifier>jdk15</classifier>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<defaultGoal>install</defaultGoal>
<finalName>sampleprj</finalName>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-eclipse-plugin</artifactId>
<configuration>
<wtpversion>1.0</wtpversion>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>dashboard-maven-plugin</artifactId>
<configuration>
<dialect>org.hibernate.dialect.MySQLInnoDBDialect</dialect>
<driverClass>com.mysql.jdbc.Driver</driverClass>
<connectionUrl>jdbc:mysql://localhost:3306/continuum?autoReconnect=true</connectionUrl>
<username>root</username>
<password>sn@pple</password>
</configuration>
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.0.3</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<reportSets>
<reportSet>
<reports>
<report>project-team</report>
<report>mailing-list</report>
<report>cim</report>
<report>issue-tracking</report>
<report>license</report>
<report>scm</report>
</reports>
</reportSet>
</reportSets>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jxr-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<configuration>
<targetJdk>${compilerTarget}</targetJdk>
<sourceEncoding>${fileEncoding}</sourceEncoding>
<excludes>
<exclude>${vm.report.exclusions}</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<configuration>
<xmlOutput>true</xmlOutput>
<effort>Max</effort>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jdepend-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>dashboard-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
</plugin>
</plugins>
</reporting>
</project>

 

 
The dashboard-maven-plugin has configuration settings pointing to connections for the Mysql database. If the database doesn't have the tables already, it will be created the project. Also each project has it's own unique ID so there is no need for multiple database schemes for the x number of projects there might be in an organization.

Supposing you have a simple application and test ready to compile, there are three goals need to generate historical trends. The first is running mvn clean install site. This compiles and generates the maven project site. The second step is running mvn dashboard:persist. This goal will take the results of the reports and store them in the database. The third goal is to run mvn dasboard:dashboard. This re-generates the reports and aggregates the historical information from each report.

When setting up an integration environment due to the lifecycle of the maven dashboard each of those goals will have to be run in order to store and generate a historical report. The result historical report will be in the target/site/ directory of the maven project called “dashboard-report-historic.html” It will show daily and weekly trends for each report specified in the project to generate. There are further configuration customization that can be done to the dashboard report.

Newer application development can benefit greatly from using Maven as their build. It's not a perfect tool but it does go into the right direction for managing software projects. As developers strive not only to produce better code, they shouldn't let long term development and refactorings allow the code start looking like the next contestant of the Biggest Loser.

0
Your rating: None
Published at DZone with permission of its author, Walter Bogaardt.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)

Comments

sub online replied on Fri, 2009/06/26 - 2:48am

I had no idea.links of londonIt's a deal.Hurry up.links of londonI changed my mind.No need to tell you. Why tell you?Tiffany JewelleryHow about this instead!Get out of here! Out of my way.You're not yourself today.Just tell it like it is.I can handle it myself.I'm not joking.The worst is yet to come.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.