diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/files/fileUtils.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/files/fileUtils.kt index 04bf09def5..64a314ad22 100644 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/files/fileUtils.kt +++ b/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 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 + } +} \ No newline at end of file diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/tasks/AbstractJPackageTask.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/tasks/AbstractJPackageTask.kt index ae3b88c40f..30836d61eb 100644 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/tasks/AbstractJPackageTask.kt +++ b/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() ?: 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) {