Skip to content

Commit

Permalink
Fix passing relative path main jar to jpackage
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexeyTsvetkov committed Apr 4, 2023
1 parent 8d78c4a commit ddc300f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,5 +108,10 @@ internal fun File.checkExistingFile(): File =
internal val File.isJarFile: Boolean
get() = name.endsWith(".jar", ignoreCase = true) && isFile

internal fun File.normalizedPath() =
if (currentOS == OS.Windows) absolutePath.replace("\\", "\\\\") else absolutePath
internal fun File.normalizedPath(base: File? = null): String {
val path = base?.let { relativeToOrNull(it)?.path } ?: absolutePath
return when (currentOS) {
OS.Windows -> path.replace("\\", "\\\\")
else -> path
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,8 @@ abstract class AbstractJPackageTask @Inject constructor(

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

if (currentOS == OS.Windows) {
Expand Down

0 comments on commit ddc300f

Please sign in to comment.