Browse Source

Fix passing relative path main jar to jpackage

pull/2973/head
Alexey Tsvetkov 2 years ago
parent
commit
ddc300f0fe
  1. 9
      gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/files/fileUtils.kt
  2. 4
      gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/tasks/AbstractJPackageTask.kt

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

@ -108,5 +108,10 @@ internal fun File.checkExistingFile(): File =
internal val File.isJarFile: Boolean internal val File.isJarFile: Boolean
get() = name.endsWith(".jar", ignoreCase = true) && isFile get() = name.endsWith(".jar", ignoreCase = true) && isFile
internal fun File.normalizedPath() = internal fun File.normalizedPath(base: File? = null): String {
if (currentOS == OS.Windows) absolutePath.replace("\\", "\\\\") else absolutePath val path = base?.let { relativeToOrNull(it)?.path } ?: absolutePath
return when (currentOS) {
OS.Windows -> path.replace("\\", "\\\\")
else -> path
}
}

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

@ -321,8 +321,8 @@ abstract class AbstractJPackageTask @Inject constructor(
val mappedJar = libsMapping[launcherMainJar.ioFile]?.singleOrNull() val mappedJar = libsMapping[launcherMainJar.ioFile]?.singleOrNull()
?: error("Main jar was not processed correctly: ${launcherMainJar.ioFile}") ?: error("Main jar was not processed correctly: ${launcherMainJar.ioFile}")
val mainJarRelative = (if (currentTarget.os == OS.Windows) "\\" else "/") + mappedJar.relativeTo(libsDir.ioFile).toString() val mainJarPath = mappedJar.normalizedPath(base = libsDir.ioFile)
cliArg("--main-jar", mainJarRelative) cliArg("--main-jar", mainJarPath)
cliArg("--main-class", launcherMainClass) cliArg("--main-class", launcherMainClass)
if (currentOS == OS.Windows) { if (currentOS == OS.Windows) {

Loading…
Cancel
Save