12

SonarQube Server 5.1.2, Sonar-Runner 2.4

As provide in Multi-moduleProject i have created a project structure as

Accounts
|
->invoice
  |
   ->src

->receipt
  |
   ->src

->sonar.properties

File:sonar.properties

sonar.projectKey=org.mycompany.acc
sonar.projectName=Account
sonar.projectVersion=1.0

sonar.sources=src

sonar.modules=invoice,receipt

invoice.sonar.projectName=Invoice
receipt.sonar.projectName=Receipt

When execute with above configuration in sonar-runner i encountered with error "src" folder is missing in "Account" directory, hope this configuration is same as the conf available in that link. As per the understanding if the configuration is fine then the Invoice and Receipt will be listed as sub project under Account Project, so what are the changes are required in above configuration to achieve multi module / project under one project.

ERROR

ERROR: Error during Sonar runner execution ERROR: Unable to execute Sonar ERROR: Caused by: The folder 'src' does not exist for 'org.mycompany.acc' (base directory = C:\Users\xyz\Accounts\.) ERROR: ERROR: To see the full stack trace of the errors, re-run SonarQube Runner with t he -e switch. ERROR: Re-run SonarQube Runner using the -X switch to enable full debug logging.

Jeevanantham
  • 984
  • 3
  • 19
  • 48

3 Answers3

22

try this:

sonar.projectKey=org.mycompany.acc
sonar.projectName=Account
sonar.projectVersion=1.0

sonar.sources=src # try to remove this by the way if you don't have suchdirectory under root folder of project

sonar.modules=invoice,receipt

invoice.sonar.projectName=Invoice
invoice.sonar.sources=invoice/src
receipt.sonar.projectName=Receipt
receipt.sonar.sources=receipt/src
-1

You can try this option, If you want scan multiple projects at same time OR in same build then try this option.

sonar.sources=invoice,receipt

zakmail007
  • 165
  • 1
  • 1
  • 4
-1

sonar.modules property was deprecated long time ago. Use sonar.sources parameter to perform a scan.
In short, you have to specify in sonar:sonar goal parameters where the sources and reportPaths are located for the required modules and declare jacoco configuration for each module respectively. As a result, it will look something like this:

  1. Jacoco plugin declaration in each module:
<plugin>
     <groupId>org.jacoco</groupId>
     <artifactId>jacoco-maven-plugin</artifactId>
     <version>0.8.7</version>
     <executions>
         <execution>
             <id>default-prepare-agent</id>
             <goals>
                 <goal>prepare-agent</goal>
             </goals>
         </execution>
         <execution>
             <id>report</id>
             <phase>test</phase>
             <goals>
                 <goal>report</goal>
             </goals>
         </execution>
     </executions>
 </plugin>
  1. Sonar goal execution:
mvn clean verify sonar:sonar /
-Dsonar.projectKey=... /
-Dsonar.host.url=... /
-Dsonar.login=... /
-Dsonar.branch.name=... /
-Dsonar.sources=../module1/src/main,../module2/src/main / 
-Dsonar.jacoco.reportPath=module1/target/jacoco.exec,module2/target/jacoco.exec

Important! It's required to specify .. before module name in -Dsonar.sources parameter because jacoco plugin in each module can only read content by relative path from it's location.

ruslangm
  • 674
  • 7
  • 19