views:

960

answers:

2

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

+2  A: 

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: http://docs.codehaus.org/display/SONAR/Collect+data

More information here:

http://docs.codehaus.org/display/SONAR/Documentation http://docs.codehaus.org/display/SONAR/Continuous+integration+engines

Mercer Traieste
+1  A: 

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"

Pablojim