Search in sources :

Example 1 with InstallationLocation

use of org.gradle.jvm.toolchain.internal.InstallationLocation in project gradle by gradle.

the class AvailableJavaHomes method discoverLocalInstallations.

private static List<JvmInstallationMetadata> discoverLocalInstallations() {
    ExecHandleFactory execHandleFactory = TestFiles.execHandleFactory();
    TemporaryFileProvider temporaryFileProvider = TestFiles.tmpDirTemporaryFileProvider(new File(SystemProperties.getInstance().getJavaIoTmpDir()));
    DefaultJvmMetadataDetector defaultJvmMetadataDetector = new DefaultJvmMetadataDetector(execHandleFactory, temporaryFileProvider);
    JvmMetadataDetector metadataDetector = new CachingJvmMetadataDetector(defaultJvmMetadataDetector);
    final List<JvmInstallationMetadata> jvms = new JavaInstallationRegistry(defaultInstallationSuppliers(), new TestBuildOperationExecutor(), OperatingSystem.current()).listInstallations().stream().map(InstallationLocation::getLocation).map(metadataDetector::getMetadata).filter(JvmInstallationMetadata::isValidInstallation).sorted(Comparator.comparing(JvmInstallationMetadata::getDisplayName).thenComparing(JvmInstallationMetadata::getLanguageVersion)).collect(Collectors.toList());
    System.out.println("Found the following JVMs:");
    for (JvmInstallationMetadata jvm : jvms) {
        String name = jvm.getDisplayName() + " " + jvm.getImplementationVersion() + " ";
        System.out.println("    " + name + " - " + jvm.getJavaHome());
    }
    return jvms;
}
Also used : TestBuildOperationExecutor(org.gradle.internal.operations.TestBuildOperationExecutor) InstallationLocation(org.gradle.jvm.toolchain.internal.InstallationLocation) JvmInstallationMetadata(org.gradle.internal.jvm.inspection.JvmInstallationMetadata) ExecHandleFactory(org.gradle.process.internal.ExecHandleFactory) DefaultJvmMetadataDetector(org.gradle.internal.jvm.inspection.DefaultJvmMetadataDetector) CachingJvmMetadataDetector(org.gradle.internal.jvm.inspection.CachingJvmMetadataDetector) JvmMetadataDetector(org.gradle.internal.jvm.inspection.JvmMetadataDetector) DefaultJvmMetadataDetector(org.gradle.internal.jvm.inspection.DefaultJvmMetadataDetector) TemporaryFileProvider(org.gradle.api.internal.file.temp.TemporaryFileProvider) CachingJvmMetadataDetector(org.gradle.internal.jvm.inspection.CachingJvmMetadataDetector) JavaInstallationRegistry(org.gradle.jvm.toolchain.internal.JavaInstallationRegistry) File(java.io.File)

Aggregations

File (java.io.File)1 TemporaryFileProvider (org.gradle.api.internal.file.temp.TemporaryFileProvider)1 CachingJvmMetadataDetector (org.gradle.internal.jvm.inspection.CachingJvmMetadataDetector)1 DefaultJvmMetadataDetector (org.gradle.internal.jvm.inspection.DefaultJvmMetadataDetector)1 JvmInstallationMetadata (org.gradle.internal.jvm.inspection.JvmInstallationMetadata)1 JvmMetadataDetector (org.gradle.internal.jvm.inspection.JvmMetadataDetector)1 TestBuildOperationExecutor (org.gradle.internal.operations.TestBuildOperationExecutor)1 InstallationLocation (org.gradle.jvm.toolchain.internal.InstallationLocation)1 JavaInstallationRegistry (org.gradle.jvm.toolchain.internal.JavaInstallationRegistry)1 ExecHandleFactory (org.gradle.process.internal.ExecHandleFactory)1