aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-batch
diff options
context:
space:
mode:
authorEvgeny Mandrikov <mandrikov@gmail.com>2012-01-17 19:21:43 +0400
committerEvgeny Mandrikov <mandrikov@gmail.com>2012-01-18 15:28:20 +0400
commitcf0426185f6b1048e83656e9a43caebfc783058f (patch)
tree6b78604eaf4912280c1a84ff053414b1a944e47d /sonar-batch
parent5edf19806b6d57c794a44c3ccda07c160b69f939 (diff)
downloadsonarqube-cf0426185f6b1048e83656e9a43caebfc783058f.tar.gz
sonarqube-cf0426185f6b1048e83656e9a43caebfc783058f.zip
SONAR-2907 Fix loading of settings from database, when used property 'sonar.branch'
Diffstat (limited to 'sonar-batch')
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/config/BatchSettingsEnhancer.java4
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/config/ProjectSettings.java16
2 files changed, 14 insertions, 6 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/config/BatchSettingsEnhancer.java b/sonar-batch/src/main/java/org/sonar/batch/config/BatchSettingsEnhancer.java
index 292f8ce155c..dc605219b88 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/config/BatchSettingsEnhancer.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/config/BatchSettingsEnhancer.java
@@ -19,6 +19,7 @@
*/
package org.sonar.batch.config;
+import org.sonar.api.CoreProperties;
import org.sonar.api.batch.bootstrap.ProjectReactor;
import org.sonar.api.database.configuration.Property;
import org.sonar.core.config.ConfigurationUtils;
@@ -42,8 +43,7 @@ public final class BatchSettingsEnhancer {
}
public void start() {
- String projectKey = reactor.getRoot().getKey();
- setIfNotDefined(ConfigurationUtils.getProjectProperties(dbFactory, projectKey));
+ setIfNotDefined(ConfigurationUtils.getProjectProperties(dbFactory, reactor.getRoot().getKey(), settings.getString(CoreProperties.PROJECT_BRANCH_PROPERTY)));
setIfNotDefined(ConfigurationUtils.getGeneralProperties(dbFactory));
settings.updateDeprecatedCommonsConfiguration();
}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/config/ProjectSettings.java b/sonar-batch/src/main/java/org/sonar/batch/config/ProjectSettings.java
index 1e45502a78b..31c668a8cd4 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/config/ProjectSettings.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/config/ProjectSettings.java
@@ -21,6 +21,7 @@ package org.sonar.batch.config;
import com.google.common.collect.Lists;
import org.apache.commons.configuration.Configuration;
+import org.sonar.api.CoreProperties;
import org.sonar.api.batch.bootstrap.ProjectDefinition;
import org.sonar.api.config.PropertyDefinitions;
import org.sonar.api.config.Settings;
@@ -51,9 +52,16 @@ public class ProjectSettings extends Settings {
public ProjectSettings load() {
clear();
+ // hack to obtain "sonar.branch" before loading settings from database
+ loadBuildProperties();
+ addEnvironmentVariables();
+ addSystemProperties();
+ String branch = getString(CoreProperties.PROJECT_BRANCH_PROPERTY);
+ clear();
+
// order is important -> bottom-up. The last one overrides all the others.
loadDatabaseGlobalSettings();
- loadDatabaseProjectSettings(projectDefinition);
+ loadDatabaseProjectSettings(projectDefinition, branch);
loadBuildProperties();
addEnvironmentVariables();
addSystemProperties();
@@ -70,11 +78,11 @@ public class ProjectSettings extends Settings {
}
}
- private void loadDatabaseProjectSettings(ProjectDefinition projectDef) {
+ private void loadDatabaseProjectSettings(ProjectDefinition projectDef, String branch) {
if (projectDef.getParent() != null) {
- loadDatabaseProjectSettings(projectDef.getParent());
+ loadDatabaseProjectSettings(projectDef.getParent(), branch);
}
- List<Property> props = ConfigurationUtils.getProjectProperties(dbFactory, projectDef.getKey());
+ List<Property> props = ConfigurationUtils.getProjectProperties(dbFactory, projectDef.getKey(), branch);
for (Property dbProperty : props) {
setProperty(dbProperty.getKey(), dbProperty.getValue());
}