Gradle task scans only one module folder

I am evaluating SonarQube using the 8.6 Community Edition. I have successfully scanned my test project and see results in SonarQube when I run the Gradle task, but it’s only showing results for one module contains one Java file. I would like to scan the other module which has HTML, CSS, and JS so I can see how the analysis works for those kinds of files.

My project structure looks like this:

Root build.gradle file specifies the SonarQube plugin and sets the properties for source encoding and the project key.

The file that is shown in SonarQube is located in the modules/SiteNavigationTemplateContextContributer/src folder. The other source folder under temple-theme don’t have any results.

I tried specifying the src folder for the themes project, but that didn’t seem to change anything.

project(":themes") {
    sonarqube {
        properties {
            property "sonar.sources", "src"

Hi @dyee,

The Gradle Scanner can automatically get the sources for all modules. In most cases, you shouldn’t have to specify anything.

Simply register sonarqube in your root build.gradle file:

# ./build.gradle

sonarqube {
    properties {
        property "sonar.projectKey", "myProject"

And remove sonarqube mentions in your project() definitions and/or module build.gradle files. You should only have 1 sonarqube block. If you want to ignore a module, you can add the following in its own build.gradle file:

# ./mymodule/build.gradle

sonarqube {
    skipProject = true



@Wouter_Admiraal, I removed the extra sonarqube block and used the block you provided in my root build.gradle file, but it still isn’t scanning my JS file in the themes module.

But it is scanning the CSS and HTML files in themes/? If yes, that’s really weird.

Can you show the contents of the build.gradle file in your themes/ module? And perhaps the contents of the root build.gradle as well?

No, it’s not scanning anything in themes/. Sorry for the confusion.

themes/ build.gradle is empty.

root build.gradle

plugins {
    id "org.sonarqube" version "3.0"

sonarqube {
    properties {
        property "sonar.projectKey", "MyTheme"

I was also playing around with SonarLint and discovered that it has issues scanning JS files when it is bound to SonarQube. I’m using nvm to manage NodeJS versions and from what I’ve read that it causes problems with scanning JS files. I think getting SonarLint to work would also solve the problem with scanning with the Gradle task.

Ah, can you run: ./gradlew sonarqube --info? Do you see any warnings or errors?

There’s the problem!

Excluding project ':themes' because it is not a valid Java project

This project is a theme project that builds into an OSGI module for a third-party platform. Is there a way to scan the HTML/JS/CSS files if it’s not a Java project?

I also get the following exception for the modules project, which seems to be a different issue.

Execution failed for task ':modules:SiteNavigationTemplateContextContributor:compileJava'.
> Could not find tools.jar. Please check that C:\Program Files\AdoptOpenJDK\jre- contains a valid JDK installation.

Yes. It shouldn’t make any difference. You can have as many languages as you wish, the scanner should trigger the correct language analyzer for each file. Here, it’s not the scanner skipping this module, I believe Gradle itself is.

The failing task is compileJava, so this is on Gradle’s side (the scanner depends on compilation for the analysis, which is why this is run when you run sonarqube). Can you check your JDK installation folder?

I think this also relates to the JDK. Googling this error seems to find mainly users that are on Windows. It even happens for users trying to build Java projects using different build tools (like Maven).

This is all very odd, because I imagine ./gradlew clean build --debug works as you expect? It produces the artifacts you expect (including for your themes/ module), without any errors?

Running clean build shows the same failures, but running the task from my IDE works. It sounds like my OS environment variables might be incorrect so the command-line isn’t finding the JDK.

I’ll look into why Gradle is skipping the theme project.