Java Code Examples for com.google.cloud.tools.managedcloudsdk.ManagedCloudSdk#isInstalled()

The following examples show how to use com.google.cloud.tools.managedcloudsdk.ManagedCloudSdk#isInstalled() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ManagedCloudSdkStartup.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
@VisibleForTesting
void checkInstallation(
    CloudSdkManager manager, ManagedCloudSdk installation, IProgressMonitor monitor)
    throws ManagedSdkVerificationException, ManagedSdkVersionMismatchException {
  if (!installation.isInstalled()) {
    CloudSdkInstallNotification.showNotification(workbench, manager::installManagedSdkAsync);
  } else if (!installation.isUpToDate()) {
    CloudSdkVersion currentVersion = getVersion(installation.getSdkHome());
    CloudSdkUpdateNotification.showNotification(
        workbench, currentVersion, manager::updateManagedSdkAsync);
  }
}
 
Example 2
Source File: CloudSdkDownloader.java    From app-maven-plugin with Apache License 2.0 4 votes vote down vote up
/**
 * Downloads/installs/updates the Cloud SDK.
 *
 * @return The cloud SDK installation directory
 */
public Path downloadIfNecessary(
    String version, Log log, List<SdkComponent> components, 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);
    }

    // install requested components
    if (components != null) {
      for (SdkComponent component : components) {
        if (!managedCloudSdk.hasComponent(component)) {
          managedCloudSdk
              .newComponentInstaller()
              .installComponent(component, 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);
  }
}