3
votes

I'm trying to do code analysis of Java unit test using maven sonar plugin. But the plugin doesn't seem to take into account my sonar properties "sonar.*". I've tried to modify simple examples and it did work either. According to MSONAR-70, the issue has been fixed and I'm using the version 2.4.

For the test, I've tried it on a simple case:

  • Clone sonar-examples.git
  • use the project sonar-examples/projects/languages/java/maven/java-maven-simple as example
  • Renamed src/main to src/test
  • In the pom.xml, add to the properties section :

    <sonar.sources>src/test/java</sonar.sources>
    <sonar.binaries>target/test-classes</sonar.binaries>
    
  • Run mvn sonar:sonar.

--> the code analysis didn't took into account my settings. The project is created on SonarQube but code as not been analyzed.

If I use the sonar-runner command line, it's analyzing the code:

sonar-runner [...] -Dsonar.sources=src/test/java 
-Dsonar.binaries=target/test-classes
 -Dsonar.language=java
 -Dsonar.sourceEncoding=UTF-8
 -Dsonar.projectKey=org.codehaus.sonar:example-java-maven
 -Dsonar.projectName="Simple Java Maven Project"
 -Dsonar.projectVersion=1.0-SNAPSHOT
1

1 Answers

-1
votes

According to a previous revision of the question, the OP solved their problem like this:

We were using SonarQube 4.0 version. Updating the version to 4.4, made the properties be taken into account.

That was in 2014; the current version now is 5.5.

The steps to upgrade can be found here:

  • Stop the old SonarQube server
  • Download and unzip the new SonarQube distribution in a fresh directory, let's say NEW_SONARQUBE_HOME.
  • Start it using the default H2 database and use the update center to install the plugins you need.
  • Manually install any custom plugins.
  • Stop the new server.
  • Update the content of the sonar.properties and wrapper.conf files located in the NEW_SONARQUBE_HOME/conf directory with the content of the related files in the OLD_SONARQUBE_HOME/conf directory (web server URL, database settings, etc.). Do not copy-paste the old files.
  • If a custom JDBC driver is used, copy it into NEW_SONARQUBE_HOME/extensions/jdbc-driver/.
  • Back up your database.
  • Remove the data/es directory.
  • Start the new web server
  • Browse to http://localhost:9000/setup (replace "localhost:9000" with your own URL) and follow the setup instructions.