How to manage different SCM branches of my project ?
Execute the maven plugin with the following parameter :
You can also set the property directly into the pom.xml :
I get a 'java.lang.OutOfMemoryError'
Increase the maven available memory by setting the environment variable :
I get a 'java.lang.StackOverflowError' with Maven 2.0.9
org.apache.maven.wagon libraries have been included in the core of Maven 2.0.9. Projects should not define these extensions anymore in their poms. That's the origin of this curious error. So just remove the following from your pom.xml :
How can I use Clover instead of Cobertura for code coverage measures ?
Just copy your Clover license file to the root directory of each module. The sonar maven plugin automatically detects its presence then executes Clover. Example on the sonar project itself (see clover.license file).
How to hide/ignore a module of multi-modules projects ?
You can't do that. A workaround is to build the modules to ignore within a profile. Example :<project>
I get a ParseException when using @SuppressWarning tag in my source code.
This bug is fixed on Sonar 1.4.
I get a SecurityException when I execute the maven plugin
The message of the root exception is
The CGLIB library available in your Maven repository is certainly signed which is not the case on IBIBLIO repository. Perhaps you or your Maven administrator have signed this jar to include it into a Java Web Start application. Unfortunately signing CGLIB jar file breaks Hibernate's use of CGLIB, as it generates proxy classes in the same package (org.sonar.commons.database.* for our context) as the original class. But the original Sonar class is not signed and the new proxy class is, generating a java.lang.SecurityException.
You must also sign Sonar libraries in your Maven repository or used unsigned CGLIB library.
Maven mirrors : the maven plugin fails to resolve org.codehaus.sonar.runtime.* dependencies
Sonar embedds its own maven repository which is used by the Sonar maven plugin to download commercial jdbc driver, pmd or checkstyle extensions, etc. Your maven settings.xml file must contain a section called <mirror> which should look like this :
According to this section, Maven redirect all call to a given repository to this central maven repository, so Sonar maven repository is never touched and Sonar maven plugin fails to resolve org.codehaus.sonar.runtime.* dependencies. Two solutions to solve this issue :
- If and only if you have Maven version 2.0.9, just change the value of <mirroOf> parameter in your setting.xml file by adding : "*,!sonar"
- Configure your central maven repository (eg. nexus, archiva or artifactory) to use the Sonar internal repository (http://sonar:9000/deploy/maven). Don't worry if this URL returns 404, it's normal. To check if it works, browse to http://<servername>/deploy/maven/README.
Note that this is a snapshots repository, so do not forget to set the repository policy to 'snapshot'.
How is calculated the Rules Compliance indicator ?
LOC = Lines Of Codes
rules_compliance_index = 1 - (total_violation_nb * 3) / LOC
efficiency_index = 1 - (efficiency_violation_nb * 3) / LOC
reliability_index = 1 - (reliability_violation_nb * 3) / LOC
with total_violation_nbre = efficiency_violation_nb + reliability_violation_nb + maintenability_violation_nb + usability_violation_nb + portability_violation_nb
Of course with that kind of calculations :
rules_compliance_index is not equal to (efficiency_index + reliability_index + ... ) / 5
and that's why you are a bit confused.
I suggest to do the following changes :
efficiency_index = 1 - (efficiency_violation_nb * 3 * 5) / LOC
reliability_index = 1 - (reliability_violation_nb * 3 * 5) / LOC
(3*5 is just a accelerator factor)
and with rules_compliance_index = (efficiency_index + reliability_index + ... ) / 5
If someone has a best idea, feel free to challenge us on this discussion ;o)
How to plug Sonar to an Apache server ?
There are several ways to plugin a web application to an Apache server. It is not specific to Sonar. You can use the mod_jk connector if Sonar is deployed on Tomcat. The mod_proxy can also be used. Here is an example of virtual host (sonar listens on the 9000 port) :