0
votes

I have the next problem. I'm developing a project in java and create sonar.properties file to use SonarQube (v6.7.2). My project have two modules. The project structur is:

my-project
  |--core-utils
      |--src
      |--target
  |--pdf-utils
      |--src
      |--target

And sonar.properties is:

First module
sonar.moduleKey=com.app.core.pdf:pdf-utils
sonar.projectBaseDir=/var/lib/jenkins/workspace/MyProject/pdf-utils
sonar.projectKey=com.app.core.pdf:pdf-utils
sonar.projectName=pdf-utils
sonar.projectVersion=0.90.0-SNAPSHOT
sonar.sources=/var/lib/jenkins/workspace/MyProject/pdf-utils/src/main/java
sonar.working.directory=/var/lib/jenkins/workspace/MyProject/pdf-utils/target/sonar
sonar.java.binaries=/var/lib/jenkins/workspace/MyProject/pdf-utils/target/classes

Second module
sonar.moduleKey=com.app.core:core-utils
sonar.projectBaseDir=/var/lib/jenkins/workspace/MyProject/core-utils
sonar.projectKey=com.app.core:core-utils
sonar.projectName=core-utils
sonar.projectVersion=0.90.0-SNAPSHOT
sonar.sources=/var/lib/jenkins/workspace/MyProject/core-utils/src/main/java
sonar.working.directory=/var/lib/jenkins/workspace/MyProject/core-utils/target/sonar
sonar.java.binaries=/var/lib/jenkins/workspace/MyProject/core-utils/target/classes

Main module
sonar.host.url=http://localhost:9000/sonar
sonar.java.source=1.6
sonar.java.target=1.6
sonar.moduleKey=com.app.core:core-all
sonar.modules=com.app.core:core-utils,com.app.core.pdf:pdf-utils
sonar.projectBaseDir=/var/lib/jenkins/workspace/MyProject
sonar.projectKey=com.app.core:core-all
sonar.projectName=core-all
sonar.projectVersion=DEV-SNAPSHOT
sonar.sourceEncoding=UTF-8

Then runs SonarScanner and the result is:

The base directory of the module 'com.app.core:core-utils' does not exist: /var/lib/jenkins/workspace/MyProject/com.app.core:core-utils

I don't know why do this if I put base directory for each module.

Thanks!!

1
Do you build with Maven?G. Ann - SonarSource Team

1 Answers

2
votes

sonar.modules stores identifiers of the children modules. You have to use child identifier as prefix of all child's sonar properties. Example:

# Main module
sonar.host.url=http://localhost:9000/sonar
sonar.java.source=1.6
sonar.java.target=1.6
sonar.modules=coreutils,pdfutils
sonar.projectBaseDir=/var/lib/jenkins/workspace/MyProject
sonar.projectKey=com.app.core:core-all
sonar.projectName=core-all
sonar.projectVersion=DEV-SNAPSHOT
sonar.sourceEncoding=UTF-8

# First module
pdfutils.sonar.projectBaseDir=/var/lib/jenkins/workspace/MyProject/pdf-utils
pdfutils.sonar.projectKey=com.app.core.pdf:pdf-utils
pdfutils.sonar.projectName=pdf-utils
pdfutils.sonar.sources=/var/lib/jenkins/workspace/MyProject/pdf-utils/src/main/java
pdfutils.sonar.working.directory=/var/lib/jenkins/workspace/MyProject/pdf-utils/target/sonar
pdfutils.sonar.java.binaries=/var/lib/jenkins/workspace/MyProject/pdf-utils/target/classes

# Second module
coreutils.sonar.projectBaseDir=/var/lib/jenkins/workspace/MyProject/core-utils
coreutils.sonar.projectKey=com.app.core:core-utils
coreutils.sonar.projectName=core-utils
coreutils.sonar.sources=/var/lib/jenkins/workspace/MyProject/core-utils/src/main/java
coreutils.sonar.working.directory=/var/lib/jenkins/workspace/MyProject/core-utils/target/sonar
coreutils.sonar.java.binaries=/var/lib/jenkins/workspace/MyProject/core-utils/target/classes

I also cleanup your properties:

  • sonar.moduleKey - removed from all modules
  • sonar.projectVersion - removed from children modules