开发者

Sonar Configure

开发者 https://www.devze.com 2023-02-23 12:04 出处:网络
I installed S开发者_JAVA技巧onar Plugin on my eclipse, (i ran the server .../StartSonar.bat) and when I do test connection on LocalHost:9000 its okay (Connection Sucessfull). Now What should I do to a

I installed S开发者_JAVA技巧onar Plugin on my eclipse, (i ran the server .../StartSonar.bat) and when I do test connection on LocalHost:9000 its okay (Connection Sucessfull). Now What should I do to associate my projects with sonar? I'm kind lost. I'm rookie.


If your projects are built with maven then all you need to do is run mvn sonar:sonar on your project root folder (where your pom.xml is located) and the report will get pushed to your sonar instance.

And also you need to have the sonar profile set up in your settings.xml. Example below:

<settings>
    <profiles>
        <profile>
            <id>sonar</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <properties>
                <!-- EXAMPLE FOR MYSQL -->
                <sonar.jdbc.url>
                  jdbc:mysql://localhost:9000/sonar?useUnicode=true&amp;characterEncoding=utf8
                </sonar.jdbc.url>
                <sonar.jdbc.driverClassName>com.mysql.jdbc.Driver</sonar.jdbc.driverClassName>
                <sonar.jdbc.username>sonar</sonar.jdbc.username>
                <sonar.jdbc.password>sonar</sonar.jdbc.password>

                <!-- SERVER ON A REMOTE HOST -->
                <sonar.host.url>http://localhost:9000</sonar.host.url>
            </properties>
        </profile>
     </profile>

Read more here.


To use the plugin in Eclipse SonarQube you must have a sonarQube instance (server) installed, documentation on how to do can be found at the following link http://docs.sonarqube.org/display/SONAR/Setup+and+Upgrade.

Once you have performed an initial analysis of your code, either as maven says Tomasz or sonar-runner, (http://docs.sonarqube.org/display/SONAR/Analyzing+Source+Code) you can, with sonarqube plugin for Eclipse, set a reference to the server in the General preferences Eclipse Window -> Preferences -> SonarQube -> Servers and project level should "link" or refer to said first analysis located in your server.

Once you do this, every time you make an analysis of your code with SonarQube from Eclipse, it will connect to the server, the existing evidences will be brought and will do an incremental analysis of your code with respect to information collected on the remote analysis.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号