diff --git a/app/build.gradle.kts b/app/build.gradle.kts index cf9be7c3c..ccdd34fb6 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -13,6 +13,7 @@ plugins{ } group = rootProject.group +version = rootProject.version repositories{ mavenCentral() @@ -33,6 +34,8 @@ sourceSets{ compose.desktop { application { + mainClass = "processing.app.ui.Start" + jvmArgs(*listOf( Pair("processing.version", version), Pair("processing.revision", "1300"), @@ -42,23 +45,16 @@ compose.desktop { Pair("processing.tutorials", "https://processing.org/tutorials/"), ).map { "-D${it.first}=${it.second}" }.toTypedArray()) - mainClass = "processing.app.ui.Start" - nativeDistributions{ modules("jdk.jdi", "java.compiler") targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb) packageName = "Processing" - packageVersion = rootProject.version.toString() - fileAssociation("pde", "Processing Source Code", "application/x-processing") - fileAssociation("pyde", "Processing Python Source Code", "application/x-processing") - fileAssociation("pdez", "Processing Sketch Bundle", "application/x-processing") - fileAssociation("pdex", "Processing Contribution Bundle", "application/x-processing") macOS{ bundleID = "org.processing.app" iconFile = project.file("../build/macos/processing.icns") infoPlist{ - extraKeysRawXml = plistStrings + extraKeysRawXml = layout.projectDirectory.file("info.plist").asFile.readText() } entitlementsFile.set(project.file("entitlements.plist")) runtimeEntitlementsFile.set(project.file("entitlements.plist")) @@ -74,9 +70,12 @@ compose.desktop { iconFile = project.file("../build/linux/processing.png") // Fix fonts on some Linux distributions jvmArgs("-Dawt.useSystemAAFontSettings=on") - } - appResourcesRootDir.set(layout.buildDirectory.dir("resources-bundled")) + fileAssociation("pde", "Processing Source Code", "application/x-processing") + fileAssociation("pyde", "Processing Python Source Code", "application/x-processing") + fileAssociation("pdez", "Processing Sketch Bundle", "application/x-processing") + fileAssociation("pdex", "Processing Contribution Bundle", "application/x-processing") + } } } } @@ -102,34 +101,38 @@ dependencies { implementation(libs.kaml) } +tasks.compileJava{ + options.encoding = "UTF-8" +} + + // LEGACY TASKS // Most of these are shims to be compatible with the old build system // They should be removed in the future, as we work towards making things more Gradle-native -tasks.register("copyCore"){ - val project = project(":core") - dependsOn(project.tasks.jar) - from(project.layout.buildDirectory.dir("libs")) - from(project.configurations.runtimeClasspath) - into(layout.buildDirectory.dir("resources-bundled/common/core/library")) +val composeResources = { subPath: String -> layout.buildDirectory.dir("resources-bundled/common/$subPath") } +compose.desktop.application.nativeDistributions.appResourcesRootDir.set(composeResources("../")) + +tasks.register("includeCore"){ + val core = project(":core") + dependsOn(core.tasks.jar) + from(core.layout.buildDirectory.dir("libs")) + from(core.configurations.runtimeClasspath) + into(composeResources("core/library")) } -tasks.register("copyJava"){ - val project = project(":java") - dependsOn(project.tasks.jar) - from(project.layout.buildDirectory.dir("libs")) - from(project.configurations.runtimeClasspath) - into(layout.buildDirectory.dir("resources-bundled/common/modes/java/mode")) +tasks.register("includeJavaMode") { + val java = project(":java") + dependsOn(java.tasks.jar) + from(java.layout.buildDirectory.dir("libs")) + from(java.configurations.runtimeClasspath) + into(composeResources("modes/java/mode")) duplicatesStrategy = DuplicatesStrategy.EXCLUDE } -tasks.register("downloadJDK") { - val os: OperatingSystem = DefaultNativePlatform.getCurrentOperatingSystem() - val arch: String = System.getProperty("os.arch").let { originalArch -> - when (originalArch) { - "amd64" -> "x64" - "x86_64" -> "x64" - else -> originalArch - } +tasks.register("includeJdk") { + val os = DefaultNativePlatform.getCurrentOperatingSystem() + val arch = when (System.getProperty("os.arch")) { + "amd64", "x86_64" -> "x64" + else -> System.getProperty("os.arch") } - val platform = when { os.isWindows -> "windows" os.isMacOsX -> "mac" @@ -147,73 +150,65 @@ tasks.register("downloadJDK") { "hotspot/normal/eclipse?project=jdk") val extension = if (os.isWindows) "zip" else "tar.gz" - dest(layout.buildDirectory.file("jdk-$platform-$arch.$extension")) + val jdk = layout.buildDirectory.file("tmp/jdk-$platform-$arch.$extension") + dest(jdk) overwrite(false) -} -tasks.register("unzipJDK") { - val dl = tasks.findByPath("downloadJDK") as Download - dependsOn(dl) - - val os = DefaultNativePlatform.getCurrentOperatingSystem() - val archive = if (os.isWindows) { - zipTree(dl.dest) - } else { - tarTree(dl.dest) - } - - from(archive){ eachFile{ permissions{ unix("755") } } } - into(layout.buildDirectory.dir("resources-bundled/common")) -} -tasks.register("copyShared"){ - from("../build/shared/") - into(layout.buildDirectory.dir("resources-bundled/common")) -} -tasks.register("downloadProcessingExamples") { - src("https://github.com/processing/processing-examples/archive/refs/heads/main.zip") - dest(layout.buildDirectory.file("tmp/processing-examples.zip")) - overwrite(false) -} -tasks.register("unzipExamples") { - val dl = tasks.findByPath("downloadProcessingExamples") as Download - dependsOn(dl) - from(zipTree(dl.dest)){ // remove top level directory - exclude("processing-examples-main/README.md") - exclude("processing-examples-main/.github/**") - eachFile { relativePath = RelativePath(true, *relativePath.segments.drop(1).toTypedArray()) } - includeEmptyDirs = false - } - into(layout.buildDirectory.dir("resources-bundled/common/modes/java/examples")) -} -tasks.register("downloadProcessingWebsiteExamples") { - src("https://github.com/processing/processing-website/archive/refs/heads/main.zip") - dest(layout.buildDirectory.file("tmp/processing-website.zip")) - overwrite(false) -} -tasks.register("unzipWebsiteExamples") { - val dl = tasks.findByPath("downloadProcessingWebsiteExamples") as Download - dependsOn(dl) - dependsOn("unzipExamples") - print(dl.dest) - from(zipTree(dl.dest)){ - include("processing-website-main/content/examples/**") - eachFile { relativePath = RelativePath(true, *relativePath.segments.drop(3).toTypedArray()) } - includeEmptyDirs = false - exclude { - it.name.contains(".es.") || it.name == "liveSketch.js" + doLast { + copy { + val archive = if (os.isWindows) { zipTree(jdk) } else { tarTree(jdk) } + from(archive){ eachFile{ permissions{ unix("755") } } } + into(composeResources("")) } } - into(layout.buildDirectory.dir("resources-bundled/common/modes/java/examples")) } -tasks.register("copyJavaMode"){ - dependsOn("unzipExamples","unzipWebsiteExamples") - dependsOn(project(":java").tasks.named("extraResources")) - from(project(":java").layout.buildDirectory.dir("resources-bundled")) - into(layout.buildDirectory.dir("resources-bundled")) +tasks.register("includeSharedAssets"){ + from("../build/shared/") + into(composeResources("")) +} +tasks.register("includeProcessingExamples") { + val examples = layout.buildDirectory.file("tmp/processing-examples.zip") + src("https://github.com/processing/processing-examples/archive/refs/heads/main.zip") + dest(examples) + overwrite(false) + doLast{ + copy{ + from(zipTree(examples)){ // remove top level directory + exclude("processing-examples-main/README.md") + exclude("processing-examples-main/.github/**") + eachFile { relativePath = RelativePath(true, *relativePath.segments.drop(1).toTypedArray()) } + includeEmptyDirs = false + } + into(composeResources("/modes/java/examples")) + } + } +} +tasks.register("includeProcessingWebsiteExamples") { + val examples = layout.buildDirectory.file("tmp/processing-website.zip") + src("https://github.com/processing/processing-website/archive/refs/heads/main.zip") + dest(examples) + overwrite(false) + doLast{ + copy{ + from(zipTree(examples)){ + include("processing-website-main/content/examples/**") + eachFile { relativePath = RelativePath(true, *relativePath.segments.drop(3).toTypedArray()) } + includeEmptyDirs = false + exclude { it.name.contains(".es.") || it.name == "liveSketch.js" } + } + into(composeResources("modes/java/examples")) + } + } +} +tasks.register("includeJavaModeResources") { + val java = project(":java") + dependsOn(java.tasks.named("extraResources")) + from(java.layout.buildDirectory.dir("resources-bundled")) + into(composeResources("../")) } tasks.register("renameWindres") { - dependsOn("copyJavaMode", "copyShared", "unzipJDK") - val dir = layout.buildDirectory.dir("resources-bundled/common/modes/java/application/launch4j/bin/") - val os: OperatingSystem = DefaultNativePlatform.getCurrentOperatingSystem() + dependsOn("includeSharedAssets","includeJavaModeResources") + val dir = composeResources("modes/java/application/launch4j/bin/") + val os = DefaultNativePlatform.getCurrentOperatingSystem() val platform = when { os.isWindows -> "windows" os.isMacOsX -> "macos" @@ -227,103 +222,16 @@ tasks.register("renameWindres") { into(dir) } afterEvaluate { - tasks.findByName("prepareAppResources")?.dependsOn("unzipJDK","copyShared", "copyCore", "copyJava", "unzipExamples","renameWindres", "copyJavaMode") - tasks.register("setExecutablePermissions") { - description = "Sets executable permissions on binaries in Processing.app resources" - group = "compose desktop" - - doLast { - val resourcesPath = layout.buildDirectory.dir("compose/binaries") - fileTree(resourcesPath) { - include("**/resources/**/bin/**") - include("**/resources/**/*.sh") - include("**/resources/**/*.dylib") - include("**/resources/**/*.so") - include("**/resources/**/*.exe") - }.forEach { file -> - if (file.isFile) { - file.setExecutable(true, false) - } - } - } + tasks.named("prepareAppResources").configure { + dependsOn( + "includeCore", + "includeJavaMode", + "includeJdk", + "includeSharedAssets", + "includeProcessingExamples", + "includeProcessingWebsiteExamples", + "includeJavaModeResources", + "renameWindres" + ) } - tasks.findByName("createDistributable")?.finalizedBy("setExecutablePermissions") -} - -val plistStrings: String - get() = """ - CFBundleURLTypes - - - CFBundleURLName - org.processing.app - CFBundleURLSchemes - - pde - - - - CFBundleDocumentTypes - - - CFBundleTypeExtensions - - pde - - LSTypeIsPackage - - CFBundleTypeIconFile - macos/pde.icns - CFBundleTypeName - Processing Source Code - CFBundleTypeRole - Editor - - - CFBundleTypeExtensions - - pyde - - LSTypeIsPackage - - CFBundleTypeIconFile - macos/pde.icns - CFBundleTypeName - Processing Python Source Code - CFBundleTypeRole - Editor - - - CFBundleTypeExtensions - - pdez - - LSTypeIsPackage - - CFBundleTypeIconFile - macos/pdez.icns - CFBundleTypeName - Processing Sketch Bundle - CFBundleTypeRole - Editor - - - CFBundleTypeExtensions - - pdex - - LSTypeIsPackage - - CFBundleTypeIconFile - macos/pdex.icns - CFBundleTypeName - Processing Contribution Bundle - CFBundleTypeRole - Viewer - - - NSCameraUsageDescription - The sketch you're running needs access to your video camera. - NSMicrophoneUsageDescription - The sketch you're running needs access to your microphone. -""" \ No newline at end of file +} \ No newline at end of file diff --git a/app/info.plist b/app/info.plist new file mode 100644 index 000000000..974db7d45 --- /dev/null +++ b/app/info.plist @@ -0,0 +1,74 @@ + CFBundleURLTypes + + + CFBundleURLName + org.processing.app + CFBundleURLSchemes + + pde + + + + CFBundleDocumentTypes + + + CFBundleTypeExtensions + + pde + + LSTypeIsPackage + + CFBundleTypeIconFile + macos/pde.icns + CFBundleTypeName + Processing Source Code + CFBundleTypeRole + Editor + + + CFBundleTypeExtensions + + pyde + + LSTypeIsPackage + + CFBundleTypeIconFile + macos/pde.icns + CFBundleTypeName + Processing Python Source Code + CFBundleTypeRole + Editor + + + CFBundleTypeExtensions + + pdez + + LSTypeIsPackage + + CFBundleTypeIconFile + macos/pdez.icns + CFBundleTypeName + Processing Sketch Bundle + CFBundleTypeRole + Editor + + + CFBundleTypeExtensions + + pdex + + LSTypeIsPackage + + CFBundleTypeIconFile + macos/pdex.icns + CFBundleTypeName + Processing Contribution Bundle + CFBundleTypeRole + Viewer + + + NSCameraUsageDescription + The sketch you're running needs access to your video camera. + NSMicrophoneUsageDescription + The sketch you're running needs access to your microphone. \ No newline at end of file