Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sonar project integration

Tags:

Hi Ladies and Gentlemen,

We've quite big project with own build framework, based mostly on Java (however other languages exist).

We'd like to use Sonar Hudson plugin to graphically present various code metrics. How do we do this?

Do we need to change project structure and bring it to maven or there is a workaround to just specify where to get test results and other artifacts from?

Thank you

like image 528
Bogdan Avatar asked Aug 04 '09 14:08

Bogdan


2 Answers

The method we are using is this:

  • we built a custom pom.xml build file specific for sonar (we are using ant for other build purposes)
  • it only has to perform test well, so specified hardcoded dependency references with

    <scope>system</scope>
    
  • we didn't change the project structure for maven, you can specify in maven custom scr, test, resources directories (as long as you have only one src and test directory)

  • the command used in CI is

    mvn clean compile sonar:sonar
    

We are using Continuum for the CI part, but it should work just as well in Hudson.

This method did not change any other build items, it's just custom made for Sonar. But it does open the way for a Continuous Integration (daily) build, or for using maven as a build tool. This method is similar to the "sonar light mode" described here

More information here:

  • http://docs.sonarqube.org/display/SONAR/Documentation
  • http://docs.codehaus.org/display/SONAR/Continuous+Integration
like image 84
Mercer Traieste Avatar answered Oct 02 '22 23:10

Mercer Traieste


You can use sonar without Maven. you just have to tell it where the rport files are with properties: sonar.cobertura.reportPath, sonar.clover.reportPath, sonar.surefire.reportsPath…

See here: http://sonar.codehaus.org/tag/ant/

There's a tick box to set these values when configuring the build in hudson - it is called "Check if this project is NOT built with maven2"

like image 20
Pablojim Avatar answered Oct 03 '22 00:10

Pablojim