Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SCANGRADLE-152 Fix issue with "sonar.tests" in child modules #234

Merged
merged 2 commits into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,10 @@ private void computeDefaultProperties(Project project, Map<String, Object> prope

overrideWithUserDefinedProperties(project, rawProperties);

// This is required if "sonar.sources" are neither found nor defined by user
// These empty assignments are required because modules with no `sonar.sources` or `sonar.tests` value inherit the value from their parent module.
// This can eventually lead to a double indexing issue in the scanner-engine.
rawProperties.putIfAbsent(ScanProperties.PROJECT_SOURCE_DIRS, "");
rawProperties.putIfAbsent(ScanProperties.PROJECT_TEST_DIRS, "");

if (project.equals(targetProject)) {
rawProperties.putIfAbsent("sonar.projectKey", computeProjectKey());
Expand Down
10 changes: 5 additions & 5 deletions src/test/groovy/org/sonarqube/gradle/GradleKtsTests.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class GradleKtsTests extends Specification {

then:
props["sonar.sources"] == buildFile.toRealPath().toString()
!props.containsKey("sonar.tests")
props["sonar.tests"] == ""
}

def "add only settings file to sources when only settings file is in kotlin dsl"() {
Expand All @@ -104,7 +104,7 @@ class GradleKtsTests extends Specification {

then:
props["sonar.sources"] == settingsFile.toRealPath().toString()
!props.containsKey("sonar.tests")
props["sonar.tests"] == ""
}

def "add only build file to sources when no settings found"() {
Expand All @@ -124,7 +124,7 @@ class GradleKtsTests extends Specification {

then:
props["sonar.sources"] == buildFile.toRealPath().toString()
!props.containsKey("sonar.tests")
props["sonar.tests"] == ""
}

def "add nothing to sources when Groovy dsl is used"() {
Expand All @@ -145,7 +145,7 @@ class GradleKtsTests extends Specification {

then:
props["sonar.sources"] == ""
!props.containsKey("sonar.tests")
props["sonar.tests"] == ""
}

def "add nothing to sources when Groovy dsl is used and no settings"() {
Expand All @@ -165,7 +165,7 @@ class GradleKtsTests extends Specification {

then:
props["sonar.sources"] == ""
!props.containsKey("sonar.tests")
props["sonar.tests"] == ""
}

def "add .gradle.kts files to sources only once"() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ class SonarQubePluginTest extends Specification {
def properties = parentSonarTask().properties.get()

then:
!properties.containsKey("sonar.tests")
properties["sonar.tests"].isEmpty()
!properties.containsKey("sonar.surefire.reportsPath")
!properties.containsKey("sonar.junit.reportsPath")
}
Expand Down