void (@NotNull Project project, @NotNull String name, @NotNull String type, @NotNull String home) { ApplicationManager.getApplication().invokeAndWait(() -> { WriteAction.run(() -> { Sdk sdk = setup(name, type, home); ProjectRootManager rootManager = ProjectRootManager.getInstance(project); Sdk projectSdk = rootManager.getProjectSdk(); if (!Objects.equals(projectSdk, sdk)) { LOG.info("Project uses different SDK: " + projectSdk + " " + "(sdkName is " + rootManager.getProjectSdkName() + ", " + "type " + rootManager.getProjectSdkTypeName() + "). Updating..."); rootManager.setProjectSdk(sdk); } LOG.info("Project SDK is set to use the new SDK"); for (Module module : ModuleManager.getInstance(project).getModules()) { Sdk moduleSdk = ModuleRootManager.getInstance(module).getSdk(); if (!Objects.equals(moduleSdk, sdk)) { LOG.info("Module " + module.getName() + " uses different SDK: " + moduleSdk + " IGNORING!"); } } }); }); }