]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-5186 Fix validation when property is set from command line
authorJulien HENRY <julien.henry@sonarsource.com>
Tue, 8 Apr 2014 14:21:41 +0000 (16:21 +0200)
committerJulien HENRY <julien.henry@sonarsource.com>
Tue, 8 Apr 2014 14:21:41 +0000 (16:21 +0200)
sonar-batch/src/main/java/org/sonar/batch/scan/ProjectReactorValidator.java
sonar-batch/src/test/java/org/sonar/batch/scan/ProjectReactorValidatorTest.java

index 9eaf9c677e79c4fadf9db8464b15004a81dbeaee..67a226151d367879202dab26dbaffb04598790ce 100644 (file)
@@ -57,6 +57,8 @@ public class ProjectReactorValidator {
     String rootProjectKey = ComponentKeys.createKey(reactor.getRoot().getKey(), branch);
 
     List<String> validationMessages = new ArrayList<String>();
+    checkDeprecatedProperties(validationMessages);
+
     for (ProjectDefinition moduleDef : reactor.getProjects()) {
       validateModule(moduleDef, validationMessages, branch, rootProjectKey);
     }
@@ -79,8 +81,6 @@ public class ProjectReactorValidator {
   }
 
   private void validateModule(ProjectDefinition moduleDef, List<String> validationMessages, @Nullable String branch, String rootProjectKey) {
-    checkDeprecatedProperties(moduleDef, validationMessages);
-
     if (!ComponentKeys.isValidModuleKey(moduleDef.getKey())) {
       validationMessages.add(String.format("\"%s\" is not a valid project or module key. "
         + "Allowed characters are alphanumeric, '-', '_', '.' and ':', with at least one non-digit.", moduleDef.getKey()));
@@ -106,8 +106,8 @@ public class ProjectReactorValidator {
     }
   }
 
-  private void checkDeprecatedProperties(ProjectDefinition moduleDef, List<String> validationMessages) {
-    if (moduleDef.getProperties().getProperty(SONAR_PHASE) != null) {
+  private void checkDeprecatedProperties(List<String> validationMessages) {
+    if (settings.getString(SONAR_PHASE) != null) {
       validationMessages.add(String.format("Property \"%s\" is deprecated. Please remove it from your configuration.", SONAR_PHASE));
     }
   }
index fe2101a956842a44e933ea01d80bcf051a6b76b3..a3b5dc26e6757abc359990f956772c1354c9cb4b 100644 (file)
@@ -232,7 +232,7 @@ public class ProjectReactorValidatorTest {
   @Test
   public void fail_with_deprecated_sonar_phase() {
     ProjectReactor reactor = createProjectReactor("foo");
-    reactor.getRoot().setProperty("sonar.phase", "phase");
+    settings.setProperty("sonar.phase", "phase");
 
     thrown.expect(SonarException.class);
     thrown.expectMessage("\"sonar.phase\" is deprecated");