Search in sources :

Example 1 with JvmInstallationMetadata

use of org.gradle.internal.jvm.inspection.JvmInstallationMetadata in project gradle by gradle.

the class ToolchainReportRenderer method printInvalidToolchains.

public void printInvalidToolchains(List<ReportableToolchain> invalidToolchains) {
    if (!invalidToolchains.isEmpty()) {
        StyledTextOutput output = getTextOutput();
        output.withStyle(Identifier).println(" + Invalid toolchains");
        for (ReportableToolchain toolchain : invalidToolchains) {
            JvmInstallationMetadata metadata = toolchain.metadata;
            output.withStyle(Identifier).println("     + " + metadata.getJavaHome());
            final String paddedErrorType = Strings.padEnd("Error:", 20, ' ');
            getTextOutput().withStyle(Normal).format("       | %s", paddedErrorType);
            getTextOutput().withStyle(Description).println(metadata.getErrorMessage());
        }
        output.println();
    }
}
Also used : JvmInstallationMetadata(org.gradle.internal.jvm.inspection.JvmInstallationMetadata) StyledTextOutput(org.gradle.internal.logging.text.StyledTextOutput)

Example 2 with JvmInstallationMetadata

use of org.gradle.internal.jvm.inspection.JvmInstallationMetadata in project gradle by gradle.

the class ToolchainReportRenderer method printToolchain.

public void printToolchain(ReportableToolchain toolchain) {
    StyledTextOutput output = getTextOutput();
    JvmInstallationMetadata metadata = toolchain.metadata;
    String displayName = metadata.getDisplayName();
    output.withStyle(Identifier).println(" + " + displayName + " " + metadata.getRuntimeVersion());
    printAttribute("Location", metadata.getJavaHome().toString());
    printAttribute("Language Version", metadata.getLanguageVersion().getMajorVersion());
    printAttribute("Vendor", metadata.getVendor().getDisplayName());
    printAttribute("Architecture", metadata.getArchitecture());
    printAttribute("Is JDK", String.valueOf(metadata.hasCapability(JAVA_COMPILER)));
    printAttribute("Detected by", toolchain.location.getSource());
    output.println();
}
Also used : JvmInstallationMetadata(org.gradle.internal.jvm.inspection.JvmInstallationMetadata) StyledTextOutput(org.gradle.internal.logging.text.StyledTextOutput)

Example 3 with JvmInstallationMetadata

use of org.gradle.internal.jvm.inspection.JvmInstallationMetadata 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

JvmInstallationMetadata (org.gradle.internal.jvm.inspection.JvmInstallationMetadata)3 StyledTextOutput (org.gradle.internal.logging.text.StyledTextOutput)2 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 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