/** Checks if current SDK service is currently installing and not ready for operations. */ private boolean isInstallInProgress() { return CloudSdkService.getInstance().getStatus() == SdkStatus.INSTALLING; }
@Nullable private Path getJavaToolsBasePath() { CloudSdkService cloudSdkService = CloudSdkService.getInstance(); return cloudSdkService.getSdkHomePath() != null ? cloudSdkService.getSdkHomePath().resolve(JAVA_TOOLS_RELATIVE_PATH.toString()) : null; }
/** Checks if the default SDK saved path contains a valid Cloud SDK installation. */ public boolean isValidCloudSdk() { return validateCloudSdk(CloudSdkService.getInstance().getSdkHomePath()).isEmpty(); }
/** Checks if the default SDK stored path contains a valid Cloud SDK. */ public Set<CloudSdkValidationResult> validateCloudSdk() { CloudSdkService instance = CloudSdkService.getInstance(); return validateCloudSdk(instance != null ? instance.getSdkHomePath() : null); }
private static ApplicationServer getOrCreateAppServer() { final CloudSdkService sdkService = CloudSdkService.getInstance(); if (sdkService == null) { return null; } final AppEngineServerIntegration integration = AppEngineServerIntegration.getInstance(); // There are no distinguishing features about the App Engine servers so just return // the first one found final List<ApplicationServer> servers = ApplicationServersManager.getInstance().getApplicationServers(integration); // make sure no servers are recently disposed (see #2326) servers.removeIf(server -> !server.isDisposed()); if (!servers.isEmpty()) { return servers.iterator().next(); } return ApplicationServersManager.getInstance() .createServer(integration, new JavaeePersistentData()); }
private void setManagedSdkUiAvailable(boolean available) { if (ServiceManager.getService(PluginInfoService.class).shouldEnable(GctFeature.MANAGED_SDK)) { enableAutomaticUpdatesCheckbox.setEnabled(available); // only make it visible if managed SDK is active, not currently installing or updating, and // not up-to-date. if (available && CloudSdkServiceUserSettings.getInstance().getUserSelectedSdkServiceType() == CloudSdkServiceType.MANAGED_SDK) { ManagedCloudSdkService managedCloudSdkService = (ManagedCloudSdkService) CloudSdkService.getInstance(); updateNowButton.setEnabled( managedCloudSdkService.getStatus() == SdkStatus.READY && !managedCloudSdkService.isUpToDate()); } else { updateNowButton.setEnabled(false); } } }
CloudSdk buildCloudSdk() throws CloudSdkNotFoundException { CloudSdkService instance = CloudSdkService.getInstance(); return new CloudSdk.Builder() .sdkPath(instance != null ? instance.getSdkHomePath() : null) .build(); }
/** * Waits in background for Cloud SDK to be ready for all operations and then runs the given * runnable. If process results in error or user cancel, shows notification and does not run. This * method does not block and must be called from application UI thread. * * @param project Project to which runnable belongs. * @param afterSdkReady Runnable to execute after Cloud SDK is ready. This runnable will be * executed on the application UI thread. * @param progressMessage Message to show in progress dialog to identify which process is * starting, i.e. deployment or local server. * @param sdkStatusHandler Logger for errors etc. */ public void runWhenSdkReady( @Nullable Project project, @NotNull Runnable afterSdkReady, String progressMessage, CloudSdkStatusHandler sdkStatusHandler) { doWait( project, () -> { // at this point the installation should be either ready, failed or user cancelled. // run only if ready. if (CloudSdkService.getInstance().getStatus() == SdkStatus.READY) { ApplicationManager.getApplication().invokeLater(afterSdkReady); } }, progressMessage, sdkStatusHandler); }
/** Checks the current SDK status after waiting for readiness, notifies and logs about errors. */ private void handleErrors(CloudSdkStatusHandler sdkLogging) { // check the status of SDK after install. SdkStatus postInstallSdkStatus = CloudSdkService.getInstance().getStatus(); switch (postInstallSdkStatus) { case READY: // can continue without logging anything. break; case INSTALLING: // still installing, do nothing, up to caller to decide which message to show. break; case NOT_AVAILABLE: case INVALID: String message; NotificationType notificationType; boolean fatalSdkError = !CloudSdkService.getInstance().isInstallSupported(); if (fatalSdkError) { message = CloudSdkMessageBundle.message("managedsdk.not.available"); notificationType = NotificationType.ERROR; } else { message = sdkLogging.getErrorMessage(postInstallSdkStatus); notificationType = NotificationType.WARNING; } sdkLogging.onError(message); showCloudSdkNotification(message, notificationType); break; default: // do nothing, no error, not ready. } }
private void doUpdate() { CloudSdkService cloudSdkService = CloudSdkService.getInstance(); if (cloudSdkService instanceof ManagedCloudSdkService) { updateNotification.expire(); CloudSdkService afterNotificationCloudSdkService = CloudSdkService.getInstance(); if (afterNotificationCloudSdkService instanceof ManagedCloudSdkService) { ((ManagedCloudSdkService) afterNotificationCloudSdkService).update();
CloudSdkService cloudSdkService = CloudSdkService.getInstance(); if (cloudSdkService instanceof ManagedCloudSdkService) { ((ManagedCloudSdkService) cloudSdkService).update();
private CloudSdk createSdk(LoggingHandler loggingHandler) throws AppEngineException { if (credentialsPath == null) { loggingHandler.print( AppEngineMessageBundle.message("appengine.action.credential.not.found") + "\n"); throw new AppEngineException("Failed to create application default credentials."); } CloudSdkService cloudSdkService = CloudSdkService.getInstance(); CloudSdk.Builder sdkBuilder = new CloudSdk.Builder() .sdkPath(cloudSdkService != null ? cloudSdkService.getSdkHomePath() : null); getProjectJavaSdk(project).ifPresent(sdkBuilder::javaHome); return sdkBuilder.build(); }
private void checkCommonConfig(AppEngineDeployable deployable) throws RuntimeConfigurationError { // do not check SDK if it supports dynamic install - the deployment runner will block itself // until installation is done. CloudSdkService cloudSdkService = CloudSdkService.getInstance(); SdkStatus sdkStatus = cloudSdkService.getStatus(); if (sdkStatus != SdkStatus.READY && !cloudSdkService.isInstallSupported()) { Set<CloudSdkValidationResult> sdkValidationResult = CloudSdkValidator.getInstance().validateCloudSdk(); if (!sdkValidationResult.isEmpty()) { CloudSdkValidationResult result = Iterables.getFirst(sdkValidationResult, null); throw new RuntimeConfigurationError( AppEngineMessageBundle.message( "appengine.flex.config.server.error", result.getMessage())); } } check( deployable instanceof UserSpecifiedPathDeploymentSource || deployable.isValid(), "appengine.config.deployment.source.error"); check( StringUtils.isNotBlank(cloudProjectName), "appengine.flex.config.project.missing.message"); }
private static String getCloudSdkVersion() { try { CloudSdkService cloudSdkService = CloudSdkService.getInstance(); if (cloudSdkService == null) { return null; } CloudSdk sdk = new CloudSdk.Builder().sdkPath(cloudSdkService.getSdkHomePath()).build(); return sdk.getVersion().toString(); } catch (AppEngineException aee) { return ""; } } }
@Override public void patchParameters( @NotNull JavaParameters parameters, String originalOutputDir, @NotNull GwtFacet gwtFacet) { final ParametersList programParameters = parameters.getProgramParametersList(); programParameters.add("-server"); programParameters.add("com.google.appengine.tools.development.gwt.AppEngineLauncher"); final CloudSdkService sdkService = CloudSdkService.getInstance(); CloudSdkJavaInternals sdkInternals = CloudSdkJavaInternals.getInstance(); sdkInternals.patchJavaParametersForDevServer(parameters.getVMParametersList()); // actually these jars are added by AppEngine dev server automatically. But they need to be // added to classpath before gwt-dev.jar, because otherwise wrong jsp compiler version will be // used (see IDEA-63068) if (sdkInternals.getLibraries() != null) { for (File jar : ArrayUtil.mergeArrays(sdkInternals.getLibraries(), sdkInternals.getJspLibraries())) { parameters.getClassPath().addFirst(FileUtil.toSystemIndependentName(jar.getAbsolutePath())); } } if (sdkInternals.getToolsApiJarFile() != null) { parameters.getClassPath().add(sdkInternals.getToolsApiJarFile()); } } }
String progressMessage, CloudSdkStatusHandler sdkLogging) { CloudSdkService cloudSdkService = CloudSdkService.getInstance();
@Override public void checkConfiguration() throws RuntimeConfigurationException { if (artifactPointer == null || artifactPointer.getArtifact() == null) { throw new RuntimeConfigurationError( AppEngineMessageBundle.message("appengine.run.server.artifact.missing")); } // do not check SDK if it supports dynamic install - the deployment runner will block itself // until installation is done. CloudSdkService cloudSdkService = CloudSdkService.getInstance(); SdkStatus sdkStatus = cloudSdkService.getStatus(); if (sdkStatus != SdkStatus.READY && !cloudSdkService.isInstallSupported()) { if (!CloudSdkValidator.getInstance().isValidCloudSdk()) { throw new RuntimeConfigurationError( AppEngineMessageBundle.message("appengine.run.server.sdk.misconfigured.panel.message")); } } if (ProjectRootManager.getInstance(commonModel.getProject()).getProjectSdk() == null) { throw new RuntimeConfigurationError( AppEngineMessageBundle.getString("appengine.run.server.nojdk")); } }
CloudSdkVersionNotifier.getInstance().notifyIfVersionParseError(); CloudSdkService instance = CloudSdkService.getInstance(); CloudSdk.Builder sdkBuilder = new CloudSdk.Builder().sdkPath(instance != null ? instance.getSdkHomePath() : null);