Skip to content

Commit a1dae69

Browse files
committed
macOS Signing bugfix
[skip ci]
1 parent 4bce2d3 commit a1dae69

File tree

1 file changed

+25
-5
lines changed

1 file changed

+25
-5
lines changed

app/build.gradle.kts

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ import org.jetbrains.compose.desktop.application.dsl.TargetFormat
44
import org.jetbrains.compose.desktop.application.tasks.AbstractJPackageTask
55
import org.jetbrains.compose.internal.de.undercouch.gradle.tasks.download.Download
66
import org.jetbrains.kotlin.fir.scopes.impl.overrides
7+
import java.io.FileOutputStream
8+
import java.util.zip.ZipEntry
9+
import java.util.zip.ZipOutputStream
710

811
plugins{
912
id("java")
@@ -47,7 +50,7 @@ compose.desktop {
4750

4851
nativeDistributions{
4952
modules("jdk.jdi", "java.compiler", "jdk.accessibility")
50-
targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb)
53+
targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb, TargetFormat.Pkg)
5154
packageName = "Processing"
5255

5356
macOS{
@@ -388,7 +391,8 @@ tasks.register<Copy>("renameWindres") {
388391
tasks.register("signResources"){
389392
onlyIf { org.gradle.internal.os.OperatingSystem.current().isMacOsX }
390393
group = "compose desktop"
391-
dependsOn("prepareAppResources")
394+
dependsOn("renameWindres")
395+
finalizedBy("prepareAppResources")
392396

393397
val resourcesPath = composeResources("")
394398

@@ -415,6 +419,7 @@ tasks.register("signResources"){
415419
from(zipTree(file))
416420
into(tempDir)
417421
}
422+
file.delete()
418423
jars.add(tempDir)
419424
}
420425
fileTree(resourcesPath){
@@ -428,15 +433,31 @@ tasks.register("signResources"){
428433
exclude("*.so")
429434
exclude("*.dll")
430435
}.forEach{ file ->
431-
println("signign $file")
432436
exec {
433437
commandLine("codesign", "--timestamp", "--force", "--deep", "--sign", "Developer ID Application", file)
434438
}
435439
}
436440
}
437441
doLast {
438442
jars.forEach { file ->
439-
zipTo(file.resolve(file.nameWithoutExtension), file)
443+
FileOutputStream(File(file.parentFile, file.nameWithoutExtension)).use { fos ->
444+
ZipOutputStream(fos).use { zos ->
445+
file.walkTopDown().forEach { fileEntry ->
446+
if (fileEntry.isFile) {
447+
// Calculate the relative path for the zip entry
448+
val zipEntryPath = fileEntry.relativeTo(file).path
449+
val entry = ZipEntry(zipEntryPath)
450+
zos.putNextEntry(entry)
451+
452+
// Copy file contents to the zip
453+
fileEntry.inputStream().use { input ->
454+
input.copyTo(zos)
455+
}
456+
zos.closeEntry()
457+
}
458+
}
459+
}
460+
}
440461

441462
file.deleteRecursively()
442463
}
@@ -457,7 +478,6 @@ afterEvaluate {
457478
"includeJavaModeResources",
458479
"renameWindres"
459480
)
460-
finalizedBy()
461481
}
462482
tasks.register("setExecutablePermissions") {
463483
description = "Sets executable permissions on binaries in Processing.app resources"

0 commit comments

Comments
 (0)