11import org.gradle.internal.jvm.Jvm
2+ import org.gradle.internal.os.OperatingSystem
23import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform
34import org.jetbrains.compose.desktop.application.dsl.TargetFormat
45import org.jetbrains.compose.desktop.application.tasks.AbstractJPackageTask
@@ -135,11 +136,11 @@ tasks.compileJava{
135136val version = if (project.version == " unspecified" ) " 1.0.0" else project.version
136137
137138tasks.register<Exec >(" installCreateDmg" ) {
138- onlyIf { org.gradle.internal.os. OperatingSystem .current().isMacOsX }
139+ onlyIf { OperatingSystem .current().isMacOsX }
139140 commandLine(" arch" , " -arm64" , " brew" , " install" , " --quiet" , " create-dmg" )
140141}
141142tasks.register<Exec >(" packageCustomDmg" ){
142- onlyIf { org.gradle.internal.os. OperatingSystem .current().isMacOsX }
143+ onlyIf { OperatingSystem .current().isMacOsX }
143144 group = " compose desktop"
144145
145146 val distributable = tasks.named<AbstractJPackageTask >(" createDistributable" ).get()
@@ -169,8 +170,6 @@ tasks.register<Exec>("packageCustomDmg"){
169170 extra.add(" 25" )
170171 }
171172
172- commandLine(" brew" , " install" , " --quiet" , " create-dmg" )
173-
174173 commandLine(" create-dmg" ,
175174 " --volname" , packageName,
176175 " --volicon" , file(" macos/volume.icns" ),
@@ -187,7 +186,7 @@ tasks.register<Exec>("packageCustomDmg"){
187186}
188187
189188tasks.register<Exec >(" packageCustomMsi" ){
190- onlyIf { org.gradle.internal.os. OperatingSystem .current().isWindows }
189+ onlyIf { OperatingSystem .current().isWindows }
191190 dependsOn(" createDistributable" )
192191 workingDir = file(" windows" )
193192 group = " compose desktop"
@@ -203,20 +202,22 @@ tasks.register<Exec>("packageCustomMsi"){
203202 )
204203}
205204
206- val snapname = findProperty(" snapname" ) ? : rootProject.name
207- val snaparch = when (System .getProperty(" os.arch" )) {
208- " amd64" , " x86_64" -> " amd64"
209- " aarch64" -> " arm64"
210- else -> System .getProperty(" os.arch" )
211- }
205+
212206tasks.register(" generateSnapConfiguration" ){
213- onlyIf { org.gradle.internal.os.OperatingSystem .current().isLinux }
207+ val name = findProperty(" snapname" ) ? : rootProject.name
208+ val arch = when (System .getProperty(" os.arch" )) {
209+ " amd64" , " x86_64" -> " amd64"
210+ " aarch64" -> " arm64"
211+ else -> System .getProperty(" os.arch" )
212+ }
213+
214+ onlyIf { OperatingSystem .current().isLinux }
214215 val distributable = tasks.named<AbstractJPackageTask >(" createDistributable" ).get()
215216 dependsOn(distributable)
216217
217218 val dir = distributable.destinationDir.get()
218219 val content = """
219- name: $snapname
220+ name: $name
220221 version: $version
221222 base: core22
222223 summary: A creative coding editor
@@ -243,7 +244,7 @@ tasks.register("generateSnapConfiguration"){
243244 parts:
244245 processing:
245246 plugin: dump
246- source: deb/processing_$version -1_$snaparch .deb
247+ source: deb/processing_$version -1_$arch .deb
247248 source-type: deb
248249 stage-packages:
249250 - openjdk-17-jre
@@ -255,7 +256,7 @@ tasks.register("generateSnapConfiguration"){
255256}
256257
257258tasks.register<Exec >(" packageSnap" ){
258- onlyIf { org.gradle.internal.os. OperatingSystem .current().isLinux }
259+ onlyIf { OperatingSystem .current().isLinux }
259260 dependsOn(" packageDeb" , " generateSnapConfiguration" )
260261 group = " compose desktop"
261262
@@ -290,7 +291,7 @@ afterEvaluate{
290291 actions = emptyList()
291292 }
292293 tasks.named(" packageDistributionForCurrentOS" ).configure {
293- if (org.gradle.internal.os. OperatingSystem .current().isMacOsX
294+ if (OperatingSystem .current().isMacOsX
294295 && compose.desktop.application.nativeDistributions.macOS.notarization.appleID.isPresent
295296 ){
296297 dependsOn(" notarizeDmg" )
@@ -321,40 +322,9 @@ tasks.register<Copy>("includeJavaMode") {
321322 into(composeResources(" modes/java/mode" ))
322323 duplicatesStrategy = DuplicatesStrategy .EXCLUDE
323324}
324- tasks.register(" includeJdk" ) {
325- dependsOn(" createDistributable" )
326- doFirst {
327- val jdk = Jvm .current().javaHome.absolutePath
328- val target = layout.buildDirectory.dir(" compose/binaries" ).get().asFileTree.matching { include(" **/include.jdk" ) }
329- .files
330- .firstOrNull()
331- ?.parentFile
332- ?.resolve(" jdk" )
333- ?.absolutePath
334- ? : error(" Could not find include.jdk" )
335-
336- val isWindows = System .getProperty(" os.name" ).lowercase().contains(" win" )
337- val isMacOS = System .getProperty(" os.name" ).lowercase().contains(" mac" )
338- val command = if (isWindows) {
339- listOf (" xcopy" , " /E" , " /I" , " /Q" , jdk, target)
340- } else {
341- listOf (" cp" , " -a" , jdk, target)
342- }
343- ProcessBuilder (command).inheritIO().start().waitFor()
344-
345- if (org.gradle.internal.os.OperatingSystem .current().isMacOsX
346- && compose.desktop.application.nativeDistributions.macOS.notarization.appleID.isPresent
347- ) {
348- // Sign the main binary again since changed it.
349- val app = layout.buildDirectory.dir(" compose/binaries" ).get().asFileTree.matching { include(" **/*.app" ) }
350- .files
351- .firstOrNull()
352- ?.parentFile ? : error(" Could not find Info.plist" )
353- val signCommand = listOf (" codesign" , " --timestamp" , " --force" , " --deep" ," --options=runtime" , " --sign" , " Developer ID Application" , app.absolutePath)
354- ProcessBuilder (signCommand).inheritIO().start().waitFor()
355- }
356-
357- }
325+ tasks.register<Copy >(" includeJdk" ) {
326+ from(Jvm .current().javaHome.absolutePath)
327+ destinationDir = composeResources(" jdk" ).get().asFile
358328}
359329tasks.register<Copy >(" includeSharedAssets" ){
360330 from(" ../build/shared/" )
@@ -400,6 +370,7 @@ tasks.register<Copy>("includeJavaModeResources") {
400370 from(java.layout.buildDirectory.dir(" resources-bundled" ))
401371 into(composeResources(" ../" ))
402372}
373+ // TODO: Move to java mode
403374tasks.register<Copy >(" renameWindres" ) {
404375 dependsOn(" includeSharedAssets" ," includeJavaModeResources" )
405376 val dir = composeResources(" modes/java/application/launch4j/bin/" )
@@ -416,14 +387,9 @@ tasks.register<Copy>("renameWindres") {
416387 duplicatesStrategy = DuplicatesStrategy .INCLUDE
417388 into(dir)
418389}
419- tasks.register(" signResources" ){
420- onlyIf {
421- org.gradle.internal.os.OperatingSystem .current().isMacOsX
422- &&
423- compose.desktop.application.nativeDistributions.macOS.signing.sign.get()
424- }
425- group = " compose desktop"
390+ tasks.register(" includeProcessingResources" ){
426391 dependsOn(
392+ " includeJdk" ,
427393 " includeCore" ,
428394 " includeJavaMode" ,
429395 " includeSharedAssets" ,
@@ -432,12 +398,18 @@ tasks.register("signResources"){
432398 " includeJavaModeResources" ,
433399 " renameWindres"
434400 )
435- finalizedBy(" prepareAppResources" )
401+ finalizedBy(" signResources" )
402+ }
436403
404+ tasks.register(" signResources" ){
405+ onlyIf {
406+ OperatingSystem .current().isMacOsX
407+ &&
408+ compose.desktop.application.nativeDistributions.macOS.signing.sign.get()
409+ }
410+ group = " compose desktop"
437411 val resourcesPath = composeResources(" " )
438412
439-
440-
441413 // find jars in the resources directory
442414 val jars = mutableListOf<File >()
443415 doFirst{
@@ -470,7 +442,7 @@ tasks.register("signResources"){
470442 include(" **/*x86_64*" )
471443 include(" **/*ffmpeg*" )
472444 include(" **/ffmpeg*/**" )
473- exclude(" jdk-* /**" )
445+ exclude(" jdk/**" )
474446 exclude(" *.jar" )
475447 exclude(" *.so" )
476448 exclude(" *.dll" )
@@ -506,39 +478,32 @@ tasks.register("signResources"){
506478
507479
508480}
509- afterEvaluate {
510- tasks.named(" prepareAppResources" ).configure {
511- dependsOn(
512- " includeCore" ,
513- " includeJavaMode" ,
514- " includeSharedAssets" ,
515- " includeProcessingExamples" ,
516- " includeProcessingWebsiteExamples" ,
517- " includeJavaModeResources" ,
518- " renameWindres"
519- )
520- }
521- tasks.register(" setExecutablePermissions" ) {
522- description = " Sets executable permissions on binaries in Processing.app resources"
523- group = " compose desktop"
481+ tasks.register(" setExecutablePermissions" ) {
482+ description = " Sets executable permissions on binaries in Processing.app resources"
483+ group = " compose desktop"
524484
525- doLast {
526- val resourcesPath = layout.buildDirectory.dir(" compose/binaries" )
527- fileTree(resourcesPath) {
528- include(" **/resources/**/bin/**" )
529- include(" **/resources/**/*.sh " )
530- include(" **/resources/**/*.dylib " )
531- include(" **/resources/**/*.so " )
532- include(" **/resources/**/*.exe " )
533- }.forEach { file ->
534- if ( file.isFile) {
535- file.setExecutable( true , false )
536- }
485+ doLast {
486+ val resourcesPath = layout.buildDirectory.dir(" compose/binaries" )
487+ fileTree(resourcesPath) {
488+ include(" **/resources/**/bin/**" )
489+ include(" **/resources/**/lib/** " )
490+ include(" **/resources/**/*.sh " )
491+ include(" **/resources/**/*.dylib " )
492+ include(" **/resources/**/*.so " )
493+ include( " **/resources/**/*.exe " )
494+ }.forEach { file ->
495+ if ( file.isFile) {
496+ file.setExecutable( true , false )
537497 }
538498 }
539499 }
500+ }
501+
502+ afterEvaluate {
503+ tasks.named(" prepareAppResources" ).configure {
504+ dependsOn(" includeProcessingResources" )
505+ }
540506 tasks.named(" createDistributable" ).configure {
541- dependsOn(" signResources" )
542- finalizedBy( " includeJdk" , " setExecutablePermissions" )
507+ finalizedBy(" setExecutablePermissions" )
543508 }
544509}
0 commit comments