/*
 * Copyright 2017 ThoughtWorks, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.thoughtworks.go.utils;

public class AssertJava8 {
    public static void assertVMVersion() {
        String jvmVersion = System.getProperty("java.vm.specification.version");

        if (!"1.8".equals(jvmVersion)) {
            System.err.println("Running GoCD requires Java version 1.8. You are currently running with Java version " + jvmVersion + ". GoCD will now exit!");
            System.exit(1);
        }
    }
}

@@ -636,159 +636,502 @@
 s;%0A%0A
-public class AssertJava8 %7B%0A    public static void assertVMVersion() %7B%0A        String jvmVersion = System.getProperty(%22java.vm.specification.v
+%0Aimport org.apache.commons.lang3.JavaVersion;%0A%0Aimport java.util.Arrays;%0Aimport java.util.TreeSet;%0A%0Apublic class AssertJava8 %7B%0A    private static TreeSet%3CJavaVersion%3E SUPPORTED_VERSIONS = new TreeSet%3C%3E(Arrays.asList(%0A            JavaVersion.JAVA_1_8,%0A            JavaVersion.JAVA_9,%0A            JavaVersion.JAVA_10%0A    ));%0A%0A    public static void assertVMVersion() %7B%0A        checkSupported(JavaVersion.JAVA_RECENT);%0A    %7D%0A%0A    private static void checkSupported(JavaVersion currentJavaV
 ersion
-%22);%0A
+) %7B
 %0A   
@@ -1144,24 +1144,47 @@
 f (!
-%221.8%22.equals(jvm
+SUPPORTED_VERSIONS.contains(currentJava
 Vers
@@ -1262,11 +1262,133 @@
 ion 
-1.8
+%3E= %22 + SUPPORTED_VERSIONS.first().name() +%0A                    %22 and %3C= %22 + SUPPORTED_VERSIONS.last() +%0A                    %22
 . Yo
@@ -1437,11 +1437,19 @@
 %22 + 
-jvm
+currentJava
 Vers

Allow running on java 8-10