Sonarqube plugin not reporting src from peer multimodule projects


(Gregory Gee) #1

I am having difficulties trying to get jacoco and sonarqube to get code coverage results from the code in the library projects that are used by the web service project. This is the basic layout of my Gradle mutli-module project.

  • parent
    • library project1
    • library project2
    • webService project

Gradle 2.13 and org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.1-rc3

My parent project has the sonar properties in the build.gradle. I have an integrationTest task in the webService project. The webService project depends on the two library jar projects. The library projects have no integration test configuration. I can run my integration tests, but when I run sonarqube task, it is only reporting coverage for the webService project.

How can I get code coverage during integration tests for the dependent library project’s source code?

Each of the library project’s build.gradle looks like this. Is something missing to have jacoco and sonar scan this source?

buildscript {
  ext { springBootVersion = '1.4.1.RELEASE' }
  dependencies { classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") }

apply plugin: 'spring-boot'
jar { archiveName = 'schema.jar' }

configurations {
  all*.exclude group: "org.slf4j", module: "slf4j-simple"
  all*.exclude group: "org.hibernate", module: "hibernate-entitymanager"

dependencies {

bootRepackage { enabled = false }

Has anyone been able to do this? I found this example code and it made a little difference I think.

// get source dirs for project dependencies
FileCollection getSonarSrcDirs(List projects) {
    Set srcDirs =
    projects.each {
        def projDir = project(it).projectDir
    return files(srcDirs)
sonarqube {
    properties {
        property "sonar.sources", getSonarSrcDirs([':library1',':library2'])        

But when I run sonarqube, I get the following message.

File '/scratch/workspace/project/library1/src/main/java/' is ignored. It is not located in module basedir '/scratch/workspace/project/ws'.

Am I not allowed to have the dependent modules in a peer directory instead of a sub directory to the ws project folder?