jaumard
jaumard

Reputation: 8292

Sonar multi module Gradle Android ignore projectBaseDir

I have a problem with the configuration of Sonar, I'm trying to configure multi module for the following project:

Project:
    app
    lib
        android_core_ui
            nspcoreui
        nspi 

So I have 3 module to analyse: app, nspcoreui and nspi. I'm trying the following command

#!/usr/bin/env bash
./gradlew sonarqube -Dsonar.sourceEncoding="UTF-8" \
-Dsonar.projectVersion="3.10.0-APR-TEST.24-SNAPSHOT" \
-Dsonar.jacoco.reportPaths="app/build/jacoco/testStgDebugUnitTest.exec" \
-Dsonar.host.url="http://localhost:9000" \
-Dsonar.login="API_KEY" \
-Dsonar.projectKey="android_shop" \
-Dsonar.projectName="Android Shop" \
-Dsonar.projectBaseDir="." \
-Dsonar.modules.enabled="true" \
-Dsonar.modules="app,nspi,nspcoreui" \
-Dapp.sonar.projectKey="android_shop_app" \
-Dapp.sonar.projectName="Android Shop App" \
-Dapp.sonar.projectBaseDir="app" \
-Dapp.sonar.sources="src/main" \
-Dapp.sonar.tests="src/main/java,app/src/main/res" \
-Dnspcoreui.sonar.projectBaseDir="lib/android_core_ui/nspcoreui" \
-Dnspcoreui.sonar.projectName="Android Core UI" \
-Dnspcoreui.sonar.projectKey="android_nspcoreui" \
-Dnspcoreui.sonar.tests="src/test/java" \
-Dnspcoreui.sonar.sources="src/main/java,src/main/res" \
-Dnspi.sonar.projectBaseDir="lib/nspi" \
-Dnspi.sonar.projectName="Android NSPI" \
-Dnspi.sonar.projectKey="android_nspi" \
-Dnspi.sonar.tests="src/test/java" \
-Dnspi.sonar.sources="src/main/java,src/main/res";

My problem is that all -Dnspcoreui.sonar.projectBaseDir and Dnspi.sonar.projectBaseDir are totally ignored and the analysis failed with Project/nspcoreui doesn't exist

Correct path would be Project/lib/android_shop_ui/nspcoreui and Project/lib/nspi.

I'm using sonar classpath 'org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.6.1' and apply plugin: 'org.sonarqube' is under the three modules.

Any idea why sonar is ignoring my params ?

Upvotes: 0

Views: 2121

Answers (1)

as stated in the documentation, you have to apply the sonarqube plugin at the root project and not on every subproject you have. In the root build.gradle file:

apply plugin: "org.sonarqube"

And don't apply in on subprojects.

Then the configuration will be much more simple since the modules will be automatically discovered

Upvotes: 3

Related Questions