use of org.gradle.internal.jvm.inspection.DefaultJvmMetadataDetector 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;
}
Aggregations