*/
public class ProjectReactorValidator {
+ private static final String SONAR_PHASE = "sonar.phase";
private final Settings settings;
private final ResourceDao resourceDao;
}
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()));
}
}
+ 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;
}
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);