From: Julien HENRY Date: Tue, 8 Apr 2014 14:21:41 +0000 (+0200) Subject: SONAR-5186 Fix validation when property is set from command line X-Git-Tag: 4.3~96 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=31a769e8450a1da2c516fa042b1433059daa1325;p=sonarqube.git SONAR-5186 Fix validation when property is set from command line --- 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 9eaf9c677e7..67a226151d3 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 @@ -57,6 +57,8 @@ public class ProjectReactorValidator { String rootProjectKey = ComponentKeys.createKey(reactor.getRoot().getKey(), branch); List validationMessages = new ArrayList(); + 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 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 validationMessages) { - if (moduleDef.getProperties().getProperty(SONAR_PHASE) != null) { + private void checkDeprecatedProperties(List validationMessages) { + if (settings.getString(SONAR_PHASE) != null) { validationMessages.add(String.format("Property \"%s\" is deprecated. Please remove it from your configuration.", SONAR_PHASE)); } } 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 fe2101a9568..a3b5dc26e67 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 @@ -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");