From 5cb674fc459becdb0a76a42e3ac295918cfb4369 Mon Sep 17 00:00:00 2001 From: Julien HENRY Date: Mon, 7 Apr 2014 10:54:42 +0200 Subject: [PATCH] SONAR-5186 Drop support of "sonar.phase" => add a message --- .../org/sonar/batch/scan/ProjectReactorValidator.java | 9 +++++++++ .../sonar/batch/scan/ProjectReactorValidatorTest.java | 10 ++++++++++ 2 files changed, 19 insertions(+) diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectReactorValidator.java b/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectReactorValidator.java index 196b76513ec..9eaf9c677e7 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectReactorValidator.java +++ b/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectReactorValidator.java @@ -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 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 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; } diff --git a/sonar-batch/src/test/java/org/sonar/batch/scan/ProjectReactorValidatorTest.java b/sonar-batch/src/test/java/org/sonar/batch/scan/ProjectReactorValidatorTest.java index 491f5b9adc1..fe2101a9568 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/scan/ProjectReactorValidatorTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/scan/ProjectReactorValidatorTest.java @@ -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); -- 2.39.5