diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/issue/quickfix/GradleVersionQuickFix.kt b/plugins/gradle/src/org/jetbrains/plugins/gradle/issue/quickfix/GradleVersionQuickFix.kt index 4e0e049ec011..73a3062eba8c 100644 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/issue/quickfix/GradleVersionQuickFix.kt +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/issue/quickfix/GradleVersionQuickFix.kt @@ -25,7 +25,6 @@ import com.intellij.util.TimeoutUtil import com.intellij.util.io.createParentDirectories import com.intellij.util.io.outputStream import org.gradle.internal.impldep.com.google.common.base.Charsets -import org.gradle.internal.util.PropertiesUtils import org.gradle.util.GradleVersion import org.gradle.wrapper.WrapperExecutor import org.jetbrains.annotations.ApiStatus @@ -36,6 +35,7 @@ import org.jetbrains.plugins.gradle.settings.GradleSettings import org.jetbrains.plugins.gradle.util.GradleBundle import org.jetbrains.plugins.gradle.util.GradleConstants import org.jetbrains.plugins.gradle.util.GradleUtil +import java.io.OutputStreamWriter import java.nio.file.Paths import java.util.* import java.util.concurrent.CompletableFuture @@ -93,12 +93,7 @@ class GradleVersionQuickFix(private val projectPath: String, val wrapperPropertiesPath = Paths.get(projectPath, "gradle", "wrapper", "gradle-wrapper.properties") wrapperPropertiesPath.createParentDirectories().createFile() wrapperPropertiesFile = wrapperPropertiesPath - wrapperProperties = Properties() - wrapperProperties[WrapperExecutor.DISTRIBUTION_URL_PROPERTY] = distributionUrl - wrapperProperties[WrapperExecutor.DISTRIBUTION_BASE_PROPERTY] = "GRADLE_USER_HOME" - wrapperProperties[WrapperExecutor.DISTRIBUTION_PATH_PROPERTY] = "wrapper/dists" - wrapperProperties[WrapperExecutor.ZIP_STORE_BASE_PROPERTY] = "GRADLE_USER_HOME" - wrapperProperties[WrapperExecutor.ZIP_STORE_PATH_PROPERTY] = "wrapper/dists" + wrapperProperties = getDefaultGradleProperties(distributionUrl) } else { wrapperProperties = wrapperPropertiesFile.inputStream().use { stream -> @@ -107,8 +102,10 @@ class GradleVersionQuickFix(private val projectPath: String, wrapperProperties[WrapperExecutor.DISTRIBUTION_URL_PROPERTY] = distributionUrl } - wrapperPropertiesFile?.outputStream().use { out -> - PropertiesUtils.store(wrapperProperties, out, null as String?, Charsets.ISO_8859_1, "\n") + wrapperPropertiesFile?.outputStream()?.use { out -> + OutputStreamWriter(out, Charsets.ISO_8859_1).use { writer -> + wrapperProperties.store(writer, null) + } } LocalFileSystem.getInstance().refreshNioFiles(listOf(wrapperPropertiesFile)) } @@ -146,6 +143,14 @@ class GradleVersionQuickFix(private val projectPath: String, return future } + private fun getDefaultGradleProperties(distributionUrl: String): Properties = Properties().apply { + this[WrapperExecutor.DISTRIBUTION_URL_PROPERTY] = distributionUrl + this[WrapperExecutor.DISTRIBUTION_BASE_PROPERTY] = "GRADLE_USER_HOME" + this[WrapperExecutor.DISTRIBUTION_PATH_PROPERTY] = "wrapper/dists" + this[WrapperExecutor.ZIP_STORE_BASE_PROPERTY] = "GRADLE_USER_HOME" + this[WrapperExecutor.ZIP_STORE_PATH_PROPERTY] = "wrapper/dists" + } + companion object { private val LOG = logger() }