@@ -0,0 +1,1809 @@
+/*%0A * Copyright 2011 the original author or authors.%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *      http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0Apackage org.gradle.testing;%0A%0Aimport org.gradle.util.Jvm;%0Aimport java.io.File;%0A%0A/**%0A * Allows the tests to get hold of an alternative JAVA_HOME when needed.%0A *%0A * This is used in the DaemonLifecycleSpec to test that daemons don't use difference JAVA_HOME's between client and browser.%0A */%0Aabstract public class AvailableJavaHomes %7B%0A%0A    public static File getJavaHome(String label) %7B%0A        String value = System.getenv().get(getEnvVarName(label));%0A        return value == null ? null : new File(value);%0A    %7D%0A%0A    public static String getEnvVarName(String label) %7B%0A        return String.format(%22JDK_%25s%22, label);%0A    %7D%0A%0A    public static File getBestAlternative() %7B%0A        Jvm jvm = Jvm.current();%0A        if (jvm.isJava6Compatible()) %7B%0A            return firstAvailable(%2215%22, %2217%22);%0A        %7D else if (jvm.isJava5Compatible()) %7B%0A            return firstAvailable(%2216%22, %2217%22);%0A        %7D else %7B%0A            return null;%0A        %7D%0A    %7D%0A%0A    public static File firstAvailable(String... labels) %7B%0A        for (String label : labels) %7B%0A            File found = getJavaHome(label);%0A            if (found != null) %7B%0A                return found;%0A            %7D%0A        %7D%0A        return null;%0A    %7D%0A%7D

Add utility for finding available JAVA_HOMEs to use in our tests.