Monday, 10 June 2013

Sonar for maven

It is the easiest way to configure sonar for the maven based project.

Following are the changes you need for analyzing code using sonar.

1> Create a database for the sonar like "sonar"

2>Make a new entry into the setting.xml into the .m2 directory.

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


3> Start the server again.
4> Now execute the command mvn sonar:sonar and hit "localhost:9000" from browser.
5> It's ready for the code analsis.

Please provide me comments if I have missed any thing to make it more helpful.




No comments:

Post a Comment