Configure sonar to support Maven

Source: Internet
Author: User

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:

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.