Class JdkResolver

java.lang.Object
com.dua3.gradle.jdkprovider.resolver.JdkResolver

public class JdkResolver extends Object
Resolves a JDK installation that matches the specified requirements. The class checks for compatible local installations or provisions a new JDK using the DiscoAPI when necessary.
  • Constructor Details

    • JdkResolver

      public JdkResolver()
      Constructs a new instance of the JdkResolver.
  • Method Details

    • resolve

      public Optional<JdkInstallation> resolve(JdkQuery jdkQuery, boolean offlineMode)
      Resolves a JDK installation that matches the specified requirements. This method checks for compatible local JDK installations and, if none are found, attempts to provision a JDK using the DiscoAPI, provided offline mode is disabled.
      Parameters:
      jdkQuery - the specification of the JDK version and features required.
      offlineMode - a flag indicating whether the resolution process should avoid network communication and rely only on local installations.
      Returns:
      an Optional containing a JdkInstallation that meets the requirements, or an empty Optional if no suitable JDK could be resolved.
      Throws:
      org.gradle.api.GradleException - if the toolchain cannot be resolved due to offline mode or failure in provisioning a JDK using the DiscoAPI.
    • createLocalJdkScanner

      protected LocalJdkScanner createLocalJdkScanner()
    • createDiscoApiClient

      protected DiscoApiClient createDiscoApiClient()
    • createJdkProvisioner

      protected JdkProvisioner createJdkProvisioner()
    • readJdkSpec

      protected Optional<JdkInstallation> readJdkSpec(Path jdkHome)
    • provisionPackage

      protected Path provisionPackage(DiscoPackage pkg) throws IOException, InterruptedException
      Throws:
      IOException
      InterruptedException