Sonar scanner ignores projectBaseDir from sonar-project.properties from 4.0.0

Versions

SonarQube: Community Edition Version 10.3 (build 82913)
Scanner: sonar-scanner-npm 4.2.2
OS: Windows 11

Context:

I have a mono repo using nx; commands are run from the repo root, with working directories set for each sub-project. Each sub-project defines a sonar-project.properties that specifies the project key and project base directory (to limit source input files). Scanner runs use npx to run the most recent scanner release.

Issue

Up until 3.5.0, the projectBaseDir was processed from the properties file and applied. Since 4.0.0 was released, this setting is no longer applied and the default value for projectBaseDir is used. All releases from 4.0.0 to 4.2.2 have the issue.

Workaround:

Pin the sonar scanner version to 3.5.0.

Examples

Assume repo root is C:\Users\<***>\repo and sonar-project.properties contains

sonar.projectBaseDir=sub-project-1

Working

npx sonarqube-scanner@3.5.0 -Dproject.settings=sub-project-1/sonar-project.properties

Results in the following logs:

INFO: Base dir: C:\Users\<***>\repo\sub-project-1

Not working

npx sonarqube-scanner@4.2.2 -Dproject.settings=sub-project-1/sonar-project.properties

Results in the following logs:

INFO: Base dir: C:\Users\<***>\repo

Hello @Nick_Heath ,

The property project.settings worked before because the NPM Scanner was a wrapper around the Scanner CLI. This property also isn’t compatible with sonar.projectBaseDir. Feel free to check the documentation for more information.

project.settings isn’t supported in NPM Scanner v4+; therefore, you need to use projectBaseDir to specify the path to the subfolders.

From the root folder, you would run:

npx sonarqube-scanner@4.2.2 -Dsonar.projectBaseDir=sub-project-1
npx sonarqube-scanner@4.2.2 -Dsonar.projectBaseDir=sub-project-2

And your sonar-project.properties should exist in these locations

sub-project-1/sonar-project.properties
sub-project-2/sonar-project.properties

Would this work for you?
Benjamin