My Problem:
In a Multi-Proyect gradle configuration I have some libs organized by directories. Lets say;
root
|_AppsDirectory
|____App1
|____App2
|_LibsDirectory
|____Lib1
|____categoryDirectory1
|_______Lib2
|_______categoryDirectory2
|___________Lib3
|____categoryDirectory3
|_______Lib4
|_______Lib5
In order to make sonar work I have to change every moduleKey property to replace their â/â into â:â so that for example Lib2 subproject will set property âsonar.moduleKeyâ from its default â:LibsDirectory/categoryDirectory1:Lib2â to â:LibsDirectory:categoryDirectory1:Lib2â as slashes ar not allowed for moduleKey
Given this, my proyect buidls successfully and sonar can analyze it but in SonarQube Web, inside âCodeâ section only those modules directly hanging from its first level directory appears inside its directory (i.e. Lib1 inside LibsDirectory) but all others hangs from root.
In conclusion Iâll see the following:
root
|_AppsDirectory
|____App1
|____App2
|_LibsDirectory
|____Lib1
|_categoryDirectory1
|_Lib2
|_categoryDirectory2
|_Lib3
|_categoryDirectory3
|_Lib4
|_Lib5
So, How can I change a module Path for a module so that it only changes on sonarQubeUI and doesnât break sonar analysing?
The second point is more surprising. Could you please run ./gradlew sonarqube -Dsonar.scanner.dumpToFile=sonar.properties and send me (privately) the resulting file (you can check the content and remove sensitive data like sonar.login or sonar.password)
I think there is a misunderstanding due to the difference between Gradle subproject hierarchy, and physical folder layout.
For now, SonarQube has a concept of modules (that originally comes from Maven FYI) that is a logical view. It is not related to how your folders are structured, but instead how your declare your subprojects in Gradle.
Example:
Let say your physical layout is:
folder1
folder11
folder12
folder2
folder21
folder22
But if you root settings.gradle contains:
include 'folder1/folder11'
include 'folder1/folder12'
include 'folder2/folder21'
include 'folder2/folder22'
Then in SQ youâll end up with 4 flat modules:
folder1/folder11
folder1/folder12
folder2/folder21
folder2/folder22
If you want to mimic the folder hierarchy, you can change your Gradle config by (note that â/â are replaced by â:â):
include 'folder1:folder11'
include 'folder1:folder12'
include 'folder2:folder21'
include 'folder2:folder22'
It will make Gradle understand that folder11 is a subproject that is a child of folder1.
And it will also solve your issue of having â/â in module keys.
The good news is that we are working on dropping the concept of modules in SonarQube, and replace it by a hierarchical folder layout. You can follow progress here: https://jira.sonarsource.com/browse/MMF-365
Mmm the point is that some time ago I already tried to use : instead of / on gradle and I couldnât be able because it asked me for a certain file on every middle directory and I didnât want to set it. Iâll try again. Maybe a later change on my code makes it possible to do it.