diff options
author | Julien HENRY <julien.henry@sonarsource.com> | 2015-10-05 10:20:02 +0200 |
---|---|---|
committer | Julien HENRY <julien.henry@sonarsource.com> | 2015-10-05 14:27:50 +0200 |
commit | 2205d5242d2d2ebb579f4a20c7c2dc1a17fbe1a8 (patch) | |
tree | 2692d8f0a96e2074b5bc4fe0186daa54c4f73bdb /sonar-batch/src/main | |
parent | 1007662192640a2b93899859f4eb7b76105b0065 (diff) | |
download | sonarqube-2205d5242d2d2ebb579f4a20c7c2dc1a17fbe1a8.tar.gz sonarqube-2205d5242d2d2ebb579f4a20c7c2dc1a17fbe1a8.zip |
SONAR-6386 New modules should inherit parent settings
Diffstat (limited to 'sonar-batch/src/main')
-rw-r--r-- | sonar-batch/src/main/java/org/sonar/batch/repository/ProjectRepositories.java | 10 | ||||
-rw-r--r-- | sonar-batch/src/main/java/org/sonar/batch/scan/ModuleSettings.java | 13 |
2 files changed, 16 insertions, 7 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/repository/ProjectRepositories.java b/sonar-batch/src/main/java/org/sonar/batch/repository/ProjectRepositories.java index 4c12eb40886..2ce2759d7d4 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/repository/ProjectRepositories.java +++ b/sonar-batch/src/main/java/org/sonar/batch/repository/ProjectRepositories.java @@ -21,12 +21,10 @@ package org.sonar.batch.repository; import com.google.common.collect.HashBasedTable; import com.google.common.collect.Table; - -import javax.annotation.CheckForNull; -import javax.annotation.Nullable; - import java.util.Date; import java.util.Map; +import javax.annotation.CheckForNull; +import javax.annotation.Nullable; public class ProjectRepositories { private final Table<String, String, String> settingsByModule; @@ -61,6 +59,10 @@ public class ProjectRepositories { return fileDataByModuleAndPath; } + public boolean moduleExists(String moduleKey) { + return settingsByModule.containsRow(moduleKey); + } + public Map<String, String> settings(String moduleKey) { return settingsByModule.row(moduleKey); } diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/ModuleSettings.java b/sonar-batch/src/main/java/org/sonar/batch/scan/ModuleSettings.java index 96f085d76b2..d2719574e87 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/scan/ModuleSettings.java +++ b/sonar-batch/src/main/java/org/sonar/batch/scan/ModuleSettings.java @@ -35,13 +35,13 @@ import org.sonar.batch.repository.ProjectRepositories; */ public class ModuleSettings extends Settings { - private final ProjectRepositories projectSettingsRepo; + private final ProjectRepositories projectRepos; private final DefaultAnalysisMode analysisMode; public ModuleSettings(GlobalSettings batchSettings, ProjectDefinition moduleDefinition, ProjectRepositories projectSettingsRepo, DefaultAnalysisMode analysisMode, AnalysisContextReportPublisher contextReportPublisher) { super(batchSettings.getDefinitions()); - this.projectSettingsRepo = projectSettingsRepo; + this.projectRepos = projectSettingsRepo; this.analysisMode = analysisMode; getEncryption().setPathToSecretKey(batchSettings.getString(CoreProperties.ENCRYPTION_SECRET_KEY_PATH)); @@ -57,7 +57,14 @@ public class ModuleSettings extends Settings { private void addProjectProperties(ProjectDefinition moduleDefinition, GlobalSettings batchSettings) { addProperties(batchSettings.getProperties()); - addProperties(projectSettingsRepo.settings(moduleDefinition.getKeyWithBranch())); + ProjectDefinition def = moduleDefinition; + do { + if (projectRepos.moduleExists(def.getKeyWithBranch())) { + addProperties(projectRepos.settings(def.getKeyWithBranch())); + break; + } + def = def.getParent(); + } while (def != null); } private void addBuildProperties(ProjectDefinition project) { |