Browse Source

Escape file paths on Windows

pull/28/head
Alexey Tsvetkov 4 years ago committed by Alexey Tsvetkov
parent
commit
cc68421f2e
  1. 9
      gradle-plugins/compose-desktop-application/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/cliArgUtils.kt
  2. 8
      gradle-plugins/compose-desktop-application/src/main/kotlin/org/jetbrains/compose/desktop/application/tasks/AbstractJPackageTask.kt

9
gradle-plugins/compose-desktop-application/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/cliArgUtils.kt

@ -1,6 +1,7 @@
package org.jetbrains.compose.desktop.application.internal
import org.gradle.api.provider.Provider
import java.io.File
internal fun <T : Any?> MutableCollection<String>.cliArg(
name: String,
@ -24,4 +25,10 @@ internal fun <T : Any?> MutableCollection<String>.cliArg(
}
private fun <T : Any?> defaultToString(): (T) -> String =
{ "\"${it.toString()}\"" }
{
val asString = if (it is File) it.normalizedPath() else it.toString()
"\"$asString\""
}
private fun File.normalizedPath() =
if (currentOS == OS.Windows) absolutePath.replace("\\", "\\\\") else absolutePath

8
gradle-plugins/compose-desktop-application/src/main/kotlin/org/jetbrains/compose/desktop/application/tasks/AbstractJPackageTask.kt

@ -191,16 +191,16 @@ abstract class AbstractJPackageTask @Inject constructor(
private fun makeArgs(vararg inputDirs: File) = arrayListOf<String>().apply {
for (dir in inputDirs) {
cliArg("--input", dir.absolutePath)
cliArg("--input", dir)
}
cliArg("--type", targetFormat.id)
cliArg("--dest", destinationDir.asFile.get().absolutePath)
cliArg("--dest", destinationDir.asFile.get())
cliArg("--verbose", verbose)
cliArg("--install-dir", installationPath)
cliArg("--license-file", licenseFile.asFile.orNull?.absolutePath)
cliArg("--icon", iconFile.asFile.orNull?.absolutePath)
cliArg("--license-file", licenseFile.asFile.orNull)
cliArg("--icon", iconFile.asFile.orNull)
cliArg("--name", packageName)
cliArg("--description", packageDescription)

Loading…
Cancel
Save