diff options
author | Julien HENRY <julien.henry@sonarsource.com> | 2014-04-08 16:21:41 +0200 |
---|---|---|
committer | Julien HENRY <julien.henry@sonarsource.com> | 2014-04-08 16:21:41 +0200 |
commit | 31a769e8450a1da2c516fa042b1433059daa1325 (patch) | |
tree | 0742e972c4239d789d81bac4218e4b9e246f8090 | |
parent | 109d87e6481cd92cf65dfd274ef5a63800c6f72e (diff) | |
download | sonarqube-31a769e8450a1da2c516fa042b1433059daa1325.tar.gz sonarqube-31a769e8450a1da2c516fa042b1433059daa1325.zip |
SONAR-5186 Fix validation when property is set from command line
-rw-r--r-- | sonar-batch/src/main/java/org/sonar/batch/scan/ProjectReactorValidator.java | 8 | ||||
-rw-r--r-- | sonar-batch/src/test/java/org/sonar/batch/scan/ProjectReactorValidatorTest.java | 2 |
2 files changed, 5 insertions, 5 deletions
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<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)); } } 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"); |