From: http://www.oschina.net/question/12_17465
Http://java.dzone.com/tips/configuring-sonar-maven.
Sonar is an open-source platform for managing the quality of Java source code. From sonar 1.6, sonar has changed from a quality data reporting tool to the current code quality management platform.
Main features:
- Code coverage: the unit test shows the lines of code selected.
- Improved Coding rules
- Search encoding rules: query by name, plug-in, activation level, and category
- Project search: query by project name
- Comparison data: Compare the trend of any measurement in the same table
Next, let's configure sonar to support maven. First, in the settings. xml file of Maven:
<profile> <id>sonar</id> <activation> <activeByDefault>true</activeByDefault> </activation> <properties> <sonar.jdbc.url>jdbc:postgresql://localhost/sonar</sonar.jdbc.url> <sonar.jdbc.driver>org.postgresql.Driver</sonar.jdbc.driver> <sonar.jdbc.username>user</sonar.jdbc.username> <sonar.jdbc.password>password</sonar.jdbc.password> <!-- SERVER ON A REMOTE HOST --> <sonar.host.url>http://localhost:9000</sonar.host.url> </properties></profile>
First, you must run the sonar server and. host. specify the access address of the server in the URL. The default URL of sonar is used in the preceding configuration. The user name and password of the database must also be provided.
After doing this, you can use MVN Sonar: sonar to perform code analysis and save the results in the sonar database. This is the final result: