import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
+import java.util.Objects;
import java.util.stream.Stream;
import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
workDir = initRootProjectWorkDir(baseDir, moduleProperties);
} else {
workDir = initModuleWorkDir(baseDir, moduleProperties);
- checkUnsupportedIssueExclusions(moduleProperties);
+ checkUnsupportedIssueExclusions(moduleProperties, parent.properties());
}
return ProjectDefinition.create().setProperties(moduleProperties)
.setBuildDir(initModuleBuildDir(baseDir, moduleProperties));
}
- private void checkUnsupportedIssueExclusions(Map<String, String> moduleProperties) {
+ private void checkUnsupportedIssueExclusions(Map<String, String> moduleProperties, Map<String, String> parentProps) {
UNSUPPORTED_PROPS_FOR_MODULES.stream().forEach(p -> {
- if (moduleProperties.containsKey(p)) {
+ if (moduleProperties.containsKey(p) && !Objects.equals(moduleProperties.get(p), parentProps.get(p))) {
warnOnceUnsupportedIssueExclusions(
"Specifying issue exclusions at module level is not supported anymore. Configure the property '" + p + "' and any other issue exclusions at project level.");
}
issues = result.issuesFor(result.inputFile("moduleB/src/sampleB.xoo"));
assertThat(issues).hasSize(10);
+
+
+ // SONAR-11850 The Maven scanner replicates properties defined on the root module to all modules
+ logTester.clear();
+ result = tester.newAnalysis()
+ .properties(ImmutableMap.<String, String>builder()
+ .put("sonar.projectBaseDir", baseDir.getAbsolutePath())
+ .put("sonar.projectKey", "com.foo.project")
+ .put("sonar.modules", "moduleA,moduleB")
+ .put("sonar.sources", "src")
+ .put("sonar.scm.disabled", "true")
+ .put("sonar.issue.ignore.multicriteria", "1")
+ .put("sonar.issue.ignore.multicriteria.1.ruleKey", "*")
+ .put("sonar.issue.ignore.multicriteria.1.resourceKey", "*")
+ .put("moduleA.sonar.issue.ignore.multicriteria", "1")
+ .put("moduleA.sonar.issue.ignore.multicriteria.1.ruleKey", "*")
+ .put("moduleA.sonar.issue.ignore.multicriteria.1.resourceKey", "*")
+ .build())
+ .execute();
+
+ assertThat(logTester.logs(LoggerLevel.WARN)).isEmpty();
}
@Test