Any Maven Build tool can use Check style for code analysis.
List of items to be touched.
- Check Style Configuration rule as per your project and Company policy. Sample can be downloaded from here. Store this file in root of the project where parent pom.xml exist.
- <checkstyle.config.location>google_checks.xml</checkstyle.config.location> make this entry in your parent pom.xml
- Finally add this block in the same parent pom.xml.
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.9.1</version>
</plugin>
</plugins>
</pluginManagement>
</build>
- You are done with your changes. Run your command like “mvn clean install checkstyle:checkstyle” since you provided your config for google_checks…it will use the same if you remove the properties it will use out of box and your code analysis report would be created under /target/site as html and XML.
Please let me know if you have any question.
- Note: PMD looks better than Check-style.. One of the main reason as minimal configuration effort for JSP files…http://maven.apache.org/plugins/maven-pmd-plugin/examples/jspReport.html
- Negative part of PMD is you would not get details reports total number of lines covered, name if files,it displays only files and line number if its violated against the rule-set.
- http://emma.sourceforge.net/coverage_sample_b/index.html EMMA is good tool for sttaic Java code analysis but it does not do out of box code coverage for JSP
- Ideally. JSP should be not be candidate for code coverage, all logic of JSP should be placed as JSTL in Java class. I would recommend to stay with Check-style then if you need details reporting of static code analysis.
- If you looking for all kind of details around site using Maven and checkstyle, PMD etc this is one of the good destination http://www.avajava.com/tutorials/lessons/how-do-i-generate-a-jxr-report-for-a-site.html?page=2.