"The base directory of the module does not exist" when using "skipProject" on gradle plugin 4.0.0

When using org.sonarqube gradle plugin, we get the following error when using isSkipProject = true

* What went wrong:
Execution failed for task ':sonar'.
> The base directory of the module ':client' does not exist: /private/var/folders/hj/6wjn3yv15n7dlmqc43dft_sh0000gp/T/junit5923190893186433902/:client

Here is a minimal reproduction

settings.gradle.kts

include("client")

build.gradle.kts

plugins {
    java
    id("org.sonarqube") version "4.0.0.2929"
}

sonar {
    properties {
        property("sonar.host.url", System.getenv("SONAR_URL"))
        property("sonar.login", System.getenv("SONAR_TOKEN"))
    }
}

client/build.gradle.kts

plugins {
    java
}

sonar {
    isSkipProject = true
}

Presence or absence of java source files does not affect whether the error happens.

This happens on any version of Gradle and JDK.

My guess is you are using project.getPath() instead of project.getProjectDir() to resolve the child project’s working directory.

1 Like

Hey there

To clarify, is this changed behavior since v3.5 of the gradle plugin?

Yes, on 3.5, there is no error and the sonar task works as expected.

Warm welcome @Tom_Warner ,

Thanks for letting us know about the issue. Unfortunately I have trouble reproducing it using the example provided by you.

I tested it both using Gradle wrapper 8 and 7 and the isSkipProject setting on the child module works just fine and Sonar omits the module without any issues.

Could you add
property("sonar.scanner.dumpToFile", "some-file-path.txt") and attach the result? This would help us investigate the issue further.

Thank you

The issue has been now reproduced and the ticket created: [SONARGRADL-109] - Jira

I am going to update this thread once the issue has been fixed and/or released.

@Lukasz_Jarocki @Tom_Warner

Hi Lukasz, you tagged the wrong Tom :smiley:

1 Like

Hi @Tom_Warner

Could you try

sonar {
    skipProject = true
}

instead of

sonar {
    isSkipProject = true
}

and let us know if it remedies the issue?

With that I get the error:

Cannot access ‘skipProject’: it is private in ‘SonarExtension’

In kotlin build scripts, isSkipProject = true is the same as setSkipProject(true) so I don’t think that would change anything.

Saw this comment in the linked JIRA issue, copy pasting here for visbility:

This bug only affected users who were using deprecated ‘sonarqube’ task instead of ‘sonar’.
Until this is released, the work-around is to use ‘sonar’ in your build.gradle.

Switching from sonarqube to sonar extension in my build.gradle.kts file fixed the issue in my project. Thanks Lukasz!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.