Browse Source

Escape launcher arguments and JVM arguments with extra quotes

Resolves #465
pull/509/head
Alexey Tsvetkov 4 years ago committed by Alexey Tsvetkov
parent
commit
ceab5f0979
  1. 12
      gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/tasks/AbstractJPackageTask.kt
  2. 22
      gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/DesktopApplicationTest.kt
  3. 1
      gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/TestProjects.kt
  4. 34
      gradle-plugins/compose/src/test/test-projects/application/optionsWithSpaces/build.gradle
  5. 10
      gradle-plugins/compose/src/test/test-projects/application/optionsWithSpaces/settings.gradle
  6. 7
      gradle-plugins/compose/src/test/test-projects/application/optionsWithSpaces/src/main/kotlin/main.kt

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

@ -207,10 +207,15 @@ abstract class AbstractJPackageTask @Inject constructor(
}
cliArg("--icon", iconFile)
launcherArgs.orNull?.forEach {
cliArg("--arguments", it)
cliArg("--arguments", "'$it'")
}
launcherJvmArgs.orNull?.forEach {
cliArg("--java-options", it)
cliArg("--java-options", "'$it'")
}
if (currentOS == OS.MacOS) {
macDockName.orNull?.let { dockName ->
cliArg("--java-options", "'-Xdock:name=$dockName'")
}
}
}
@ -256,9 +261,6 @@ abstract class AbstractJPackageTask @Inject constructor(
OS.MacOS -> {
cliArg("--mac-package-name", macPackageName)
cliArg("--mac-package-identifier", nonValidatedMacBundleID)
macDockName.orNull?.let { dockName ->
cliArg("--java-options", "-Xdock:name=\"$dockName\"")
}
withValidatedMacOSSigning { signing ->
cliArg("--mac-sign", true)

22
gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/DesktopApplicationTest.kt

@ -148,4 +148,26 @@ class DesktopApplicationTest : GradlePluginTestBase() {
}
}
}
@Test
fun testOptionsWithSpaces() {
with(testProject(TestProjects.optionsWithSpaces)) {
fun testRunTask(runTask: String) {
gradle(runTask).build().checks { check ->
check.taskOutcome(runTask, TaskOutcome.SUCCESS)
check.logContains("Running test options with spaces!")
check.logContains("Arg #1=Value 1!")
check.logContains("Arg #2=Value 2!")
check.logContains("JVM system property arg=Value 3!")
}
}
testRunTask(":runDistributable")
testRunTask(":run")
gradle(":package").build().checks { check ->
check.taskOutcome(":package", TaskOutcome.SUCCESS)
}
}
}
}

1
gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/TestProjects.kt

@ -7,4 +7,5 @@ object TestProjects {
const val moduleClashCli = "application/moduleClashCli"
const val javaLogger = "application/javaLogger"
const val macOptions = "application/macOptions"
const val optionsWithSpaces = "application/optionsWithSpaces"
}

34
gradle-plugins/compose/src/test/test-projects/application/optionsWithSpaces/build.gradle

@ -0,0 +1,34 @@
import org.jetbrains.compose.desktop.application.dsl.TargetFormat
plugins {
id "org.jetbrains.kotlin.jvm"
id "org.jetbrains.compose"
}
repositories {
google()
mavenCentral()
jcenter()
maven {
url "https://maven.pkg.jetbrains.space/public/p/compose/dev"
}
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib"
implementation compose.desktop.currentOs
}
compose.desktop {
application {
mainClass = "MainKt"
nativeDistributions {
targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb)
packageVersion = "1.0.0"
packageName = "Test Package"
args("Value 1!", "Value 2!")
jvmArgs("-Dcompose.test.arg.value=Value 3!")
}
}
}

10
gradle-plugins/compose/src/test/test-projects/application/optionsWithSpaces/settings.gradle

@ -0,0 +1,10 @@
pluginManagement {
plugins {
id 'org.jetbrains.kotlin.jvm' version 'KOTLIN_VERSION_PLACEHOLDER'
id 'org.jetbrains.compose' version 'COMPOSE_VERSION_PLACEHOLDER'
}
repositories {
mavenLocal()
gradlePluginPortal()
}
}

7
gradle-plugins/compose/src/test/test-projects/application/optionsWithSpaces/src/main/kotlin/main.kt

@ -0,0 +1,7 @@
fun main(args: Array<String>) {
println("Running test options with spaces!")
for ((i, arg) in args.withIndex()) {
println("Arg #${i + 1}=$arg")
}
println("JVM system property arg=${java.lang.System.getProperty("compose.test.arg.value")}")
}
Loading…
Cancel
Save