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/" )
@@ -418,26 +389,13 @@ tasks.register<Copy>("renameWindres") {
418389}
419390tasks.register(" signResources" ){
420391 onlyIf {
421- org.gradle.internal.os. OperatingSystem .current().isMacOsX
392+ OperatingSystem .current().isMacOsX
422393 &&
423394 compose.desktop.application.nativeDistributions.macOS.signing.sign.get()
424395 }
425396 group = " compose desktop"
426- dependsOn(
427- " includeCore" ,
428- " includeJavaMode" ,
429- " includeSharedAssets" ,
430- " includeProcessingExamples" ,
431- " includeProcessingWebsiteExamples" ,
432- " includeJavaModeResources" ,
433- " renameWindres"
434- )
435- finalizedBy(" prepareAppResources" )
436-
437397 val resourcesPath = composeResources(" " )
438398
439-
440-
441399 // find jars in the resources directory
442400 val jars = mutableListOf<File >()
443401 doFirst{
@@ -506,9 +464,31 @@ tasks.register("signResources"){
506464
507465
508466}
467+ tasks.register(" setExecutablePermissions" ) {
468+ description = " Sets executable permissions on binaries in Processing.app resources"
469+ group = " compose desktop"
470+
471+ doLast {
472+ val resourcesPath = layout.buildDirectory.dir(" compose/binaries" )
473+ fileTree(resourcesPath) {
474+ include(" **/resources/**/bin/**" )
475+ include(" **/resources/**/lib/**" )
476+ include(" **/resources/**/*.sh" )
477+ include(" **/resources/**/*.dylib" )
478+ include(" **/resources/**/*.so" )
479+ include(" **/resources/**/*.exe" )
480+ }.forEach { file ->
481+ if (file.isFile) {
482+ file.setExecutable(true , false )
483+ }
484+ }
485+ }
486+ }
487+
509488afterEvaluate {
510489 tasks.named(" prepareAppResources" ).configure {
511490 dependsOn(
491+ " includeJdk" ,
512492 " includeCore" ,
513493 " includeJavaMode" ,
514494 " includeSharedAssets" ,
@@ -517,28 +497,10 @@ afterEvaluate {
517497 " includeJavaModeResources" ,
518498 " renameWindres"
519499 )
500+ finalizedBy(" signResources" )
520501 }
521- tasks.register(" setExecutablePermissions" ) {
522- description = " Sets executable permissions on binaries in Processing.app resources"
523- group = " compose desktop"
524502
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- }
537- }
538- }
539- }
540503 tasks.named(" createDistributable" ).configure {
541- dependsOn(" signResources" )
542- finalizedBy( " includeJdk" , " setExecutablePermissions" )
504+ finalizedBy(" setExecutablePermissions" )
543505 }
544506}
0 commit comments