code: public Path downloadIfNecessary(
        String version, Log log, boolean requiresAppEngineComponents, boolean offline) {
      ManagedCloudSdk managedCloudSdk = managedCloudSdkFactory.apply(version);
      if (offline) { // in offline mode, don't download anything
        return managedCloudSdk.getSdkHome();
      }
      try {
        ProgressListener progressListener = new NoOpProgressListener();
        ConsoleListener consoleListener = new CloudSdkDownloaderConsoleListener(log);
  
        if (!managedCloudSdk.isInstalled()) {
          managedCloudSdk.newInstaller().install(progressListener, consoleListener);
        }
  
        if (requiresAppEngineComponents
            && !managedCloudSdk.hasComponent(SdkComponent.APP_ENGINE_JAVA)) {
          managedCloudSdk
              .newComponentInstaller()
              .installComponent(SdkComponent.APP_ENGINE_JAVA, progressListener, consoleListener);
        }
  
        if (!managedCloudSdk.isUpToDate()) {
          managedCloudSdk.newUpdater().update(progressListener, consoleListener);
        }
  
        return managedCloudSdk.getSdkHome();
      } catch (IOException
          | SdkInstallerException
          | ManagedSdkVersionMismatchException
          | InterruptedException
          | CommandExecutionException
          | CommandExitException
          | ManagedSdkVerificationException ex) {
        throw new RuntimeException(ex);
      }
    }
docs: Downloads/installs/updates the Cloud SDK
  
  @return The cloud SDK installation directory