mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[gradle][IDEA-335663] do not corrupt encoding of the gradle.properties file
By specification all Java property files should be encoded with ISO 8859-1. `Files#newBufferedReader` read bytes from the file and decodes them into characters using the UTF-8 charset. GitOrigin-RevId: 9a6c8eaefbf8428761f0bc0abfd0a2854d22cc44
This commit is contained in:
committed by
intellij-monorepo-bot
parent
0e08afb197
commit
e7bc6ec6a3
+14
-9
@@ -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<GradleVersionQuickFix>()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user