Unit test code analysis using "sonar. *" Property and maven-sonar-plugin

I am trying to parse a Java unit test code using the maven sonar plugin. But the plugin doesn't seem to respect my sonar properties "sonar. *". I tried changing simple examples and it works too. According to MSONAR-70 the issue has been fixed and I am using version 2.4.

For a test, I tried this in a simple case:

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

    <sonar.sources>src/test/java</sonar.sources>
    <sonar.binaries>target/test-classes</sonar.binaries>
    
          

  • Start mvn sonar: sonar.

-> code analysis did not take into account my settings. The project is created on SonarQube, but the code is not parsed.

If I use the command line sonar-runner it parses 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

      

+3


source to share


1 answer


According to a previous revision of the question, the OP solved his problem as follows:

We used SonarQube 4.0 version. Upgrading to 4.4 resulted in properties being taken into account.

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



Upgrade steps can be found here :

  • Stop old SonarQube server
  • Download and unpack the new SonarQube distribution in a new directory, say NEW_SONARQUBE_HOME.
  • Run it using the default H2 database and use the update center to install the plugins you need.
  • Install any custom plugins manually.
  • Stop the new server.
  • Update the contents of the sonar.properties and wrapper.conf files located in the NEW_SONARQUBE_HOME / conf directory with the contents of the related files in the OLD_SONARQUBE_HOME / conf directory (web server URL, database settings, etc.). Do not copy or paste old files.
  • If using a custom JDBC driver, copy it to NEW_SONARQUBE_HOME / extensions / jdbc-driver /.
  • Database backup.
  • Delete data directory / es.
  • Start a new web server
  • Find http://localhost:9000/setup

    (replace "localhost: 9000" with your own URL) and follow the installation instructions.
-1


source







All Articles