* Arguments :
* <ul>
* <li>runner.home: optional path to runner home (root directory with sub-directories bin, lib and conf)</li>
- * <li>runner.settings: optional path to runner global settings, usually ${runner.home}/conf/sonar-runner.properties. This property is used only if ${runner.home} is not defined</li>
+ * <li>runner.settings: optional path to runner global settings, usually ${runner.home}/conf/sonar-runner.properties.
+ * This property is used only if ${runner.home} is not defined</li>
* <li>project.home: path to project root directory. If not set, then it's supposed to be the directory where the runner is executed</li>
* <li>project.settings: optional path to project settings. Default value is ${project.home}/sonar-project.properties.</li>
* </ul>
private void checkSonarVersion(Bootstrapper bootstrapper) {
String serverVersion = bootstrapper.getServerVersion();
- if (isVersionPriorTo2Dot6(serverVersion)) {
+ if (isUnsupportedVersion(serverVersion)) {
throw new BootstrapException("Sonar " + serverVersion
+ " does not support Standalone Runner. Please upgrade Sonar to version 2.6 or more.");
}
getClass().getClassLoader());
}
- static boolean isVersionPriorTo2Dot6(String version) {
- return isVersion(version, "1")
- || isVersion(version, "2.0")
- || isVersion(version, "2.1")
- || isVersion(version, "2.2")
- || isVersion(version, "2.3")
- || isVersion(version, "2.4")
- || isVersion(version, "2.5");
+ private static final String[] unsupportedVersions = { "1", "2.0", "2.1", "2.2", "2.3", "2.4", "2.5" };
+
+ static boolean isUnsupportedVersion(String version) {
+ for (String unsupportedVersion : unsupportedVersions) {
+ if (isVersion(version, unsupportedVersion)) {
+ return true;
+ }
+ }
+ return false;
}
static boolean isVersion(String version, String prefix) {
public class RunnerTest {
@Test
public void shouldCheckVersion() {
- assertThat(Runner.isVersionPriorTo2Dot6("1.0"), is(true));
- assertThat(Runner.isVersionPriorTo2Dot6("2.0"), is(true));
- assertThat(Runner.isVersionPriorTo2Dot6("2.1"), is(true));
- assertThat(Runner.isVersionPriorTo2Dot6("2.2"), is(true));
- assertThat(Runner.isVersionPriorTo2Dot6("2.3"), is(true));
- assertThat(Runner.isVersionPriorTo2Dot6("2.4"), is(true));
- assertThat(Runner.isVersionPriorTo2Dot6("2.4.1"), is(true));
- assertThat(Runner.isVersionPriorTo2Dot6("2.5"), is(true));
- assertThat(Runner.isVersionPriorTo2Dot6("2.6"), is(false));
+ assertThat(Runner.isUnsupportedVersion("1.0"), is(true));
+ assertThat(Runner.isUnsupportedVersion("2.0"), is(true));
+ assertThat(Runner.isUnsupportedVersion("2.1"), is(true));
+ assertThat(Runner.isUnsupportedVersion("2.2"), is(true));
+ assertThat(Runner.isUnsupportedVersion("2.3"), is(true));
+ assertThat(Runner.isUnsupportedVersion("2.4"), is(true));
+ assertThat(Runner.isUnsupportedVersion("2.4.1"), is(true));
+ assertThat(Runner.isUnsupportedVersion("2.5"), is(true));
+ assertThat(Runner.isUnsupportedVersion("2.6"), is(false));
}
/**