How to configure Sonarqube scanner for java and javascript in the same project

Viewed 7336

I have been trying to set up sonar-scanner for a Maven project containing a java module (core) and a javascript module (web).

I am able to get either java coverage data scanned and presented on my local sonarqube server, or javascript, but not both.

Here is my sonar-project.properties file, where the sonar.modules property can have one of 4 values:

### below: select just one of the 4 possible values for sonar.modules
sonar.modules = core --> get java coverage data
sonar.modules = web --> get javascript coverage data
sonar.modules = core,web --> get only java coverage data
sonar.modules = web,core --> get only java coverage data

sonar.sources=src

# javascript coverage report
web.sonar.exclusions=src/main/webapp/js/lib/**/*.js
web.sonar.javascript.lcov.reportPath = test-output/coverage/lcov.info

# java coverage report
core.sonar.java.binaries = target/classes
core.sonar.java.libraries = ../web/target/scheduler-web-3.5.0-SNAPSHOT/WEB-INF/lib
core.sonar.java.test.libraries = ../web/target/scheduler-web-3.5.0-SNAPSHOT/WEB-INF/lib
core.sonar.jacoco.reportPath = target/jacoco.exec
core.sonar.junit.reportsPath = target/surefire-reports
core.sonar.jacoco.reportMissing.force.zero = true

The key to my solution, based on the accepted answer below :

  • No changes to the top-level POM.

  • Added to web/pom.xml:

<properties>
    <sonar.javascript.lcov.reportPath>test-output/coverage/lcov.info</sonar.javascript.lcov.reportPath>
</properties>

Essentially sonar did not know where to find my lcov file.

1 Answers
Related