boolean (@NotNull String vmOptions, @NotNull GradleSettings settings) { File gradleUserHomeDir = null; if (myServiceDirectoryPathField != null) { String fieldText = trimIfPossible(myServiceDirectoryPathField.getText()); if (fieldText != null) gradleUserHomeDir = new File(fieldText); } if (gradleUserHomeDir == null) { BuildLayoutParameters buildLayoutParameters = GradleInstallationManager.defaultBuildLayoutParameters(settings.getProject()); String gradleUserHome = GradleTargetUtil.maybeGetLocalValue(buildLayoutParameters.getGradleUserHome()); if (gradleUserHome == null) { Messages.showErrorDialog(settings.getProject(), GradleBundle.message("gradle.settings.text.vm.options.migration.error.text", GradleBundle.message("gradle.settings.text.user.home.not.found.error.text")), GradleBundle.message("gradle.settings.text.vm.options.migration.error.title")); return false; } else { gradleUserHomeDir = new File(gradleUserHome); } } int result = Messages.showYesNoDialog( settings.getProject(), GradleBundle.message("gradle.settings.text.vm.options.confirm.text", new File(gradleUserHomeDir, "gradle.properties")), GradleBundle.message("gradle.title.gradle.settings"), getQuestionIcon()); if (result != Messages.YES) return false; try { // get or create project dir if (!gradleUserHomeDir.exists()) { if (!FileUtil.createDirectory(gradleUserHomeDir)) { throw new IOException("Cannot create " + gradleUserHomeDir); } } // get or create project's gradle.properties File props = new File(gradleUserHomeDir, "gradle.properties"); if (props.isDirectory()) throw new IOException(props.getPath() + " is a directory"); String original = props.exists() ? FileUtil.loadFile(props) : ""; String updated = updateVMOptions(original, vmOptions); if (!original.equals(updated)) { FileUtil.writeToFile(props, updated); } } catch (IOException e) { Messages.showErrorDialog(settings.getProject(), GradleBundle.message("gradle.settings.text.vm.options.migration.error.text", e.getMessage()), GradleBundle.message("gradle.settings.text.vm.options.migration.error.title")); return false; } return true; }