aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2014-04-07 10:54:42 +0200
committerJulien HENRY <julien.henry@sonarsource.com>2014-04-07 10:55:18 +0200
commit5cb674fc459becdb0a76a42e3ac295918cfb4369 (patch)
treea22801e740c6c3528dd244bccb23dc18f35c6de1
parentf514e44dde4be902d794672e17495aa65d49cd9a (diff)
downloadsonarqube-5cb674fc459becdb0a76a42e3ac295918cfb4369.tar.gz
sonarqube-5cb674fc459becdb0a76a42e3ac295918cfb4369.zip
SONAR-5186 Drop support of "sonar.phase" => add a message
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/scan/ProjectReactorValidator.java9
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/scan/ProjectReactorValidatorTest.java10
2 files changed, 19 insertions, 0 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 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<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;
}
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);