]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-5186 Drop support of "sonar.phase" => add a message
authorJulien HENRY <julien.henry@sonarsource.com>
Mon, 7 Apr 2014 08:54:42 +0000 (10:54 +0200)
committerJulien HENRY <julien.henry@sonarsource.com>
Mon, 7 Apr 2014 08:55:18 +0000 (10:55 +0200)
sonar-batch/src/main/java/org/sonar/batch/scan/ProjectReactorValidator.java
sonar-batch/src/test/java/org/sonar/batch/scan/ProjectReactorValidatorTest.java

index 196b76513ec80094b33d73fd6ef31619f8fb181e..9eaf9c677e79c4fadf9db8464b15004a81dbeaee 100644 (file)
@@ -41,6 +41,7 @@ import java.util.List;
  */
 public class ProjectReactorValidator {
 
+  private static final String SONAR_PHASE = "sonar.phase";
   private final Settings settings;
   private final ResourceDao resourceDao;
 
@@ -78,6 +79,8 @@ 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()));
@@ -103,6 +106,12 @@ public class ProjectReactorValidator {
     }
   }
 
+  private void checkDeprecatedProperties(ProjectDefinition moduleDef, List<String> validationMessages) {
+    if (moduleDef.getProperties().getProperty(SONAR_PHASE) != null) {
+      validationMessages.add(String.format("Property \"%s\" is deprecated. Please remove it from your configuration.", SONAR_PHASE));
+    }
+  }
+
   private boolean isSubProject(ProjectDefinition moduleDef) {
     return moduleDef.getParent() != null;
   }
index 491f5b9adc1e6408994815003f41b0db11ff50e2..fe2101a956842a44e933ea01d80bcf051a6b76b3 100644 (file)
@@ -229,6 +229,16 @@ public class ProjectReactorValidatorTest {
     validator.validate(reactor);
   }
 
+  @Test
+  public void fail_with_deprecated_sonar_phase() {
+    ProjectReactor reactor = createProjectReactor("foo");
+    reactor.getRoot().setProperty("sonar.phase", "phase");
+
+    thrown.expect(SonarException.class);
+    thrown.expectMessage("\"sonar.phase\" is deprecated");
+    validator.validate(reactor);
+  }
+
   private ProjectReactor createProjectReactor(String projectKey) {
     ProjectDefinition def = ProjectDefinition.create().setProperty(CoreProperties.PROJECT_KEY_PROPERTY, projectKey);
     ProjectReactor reactor = new ProjectReactor(def);