mirror of
https://github.com/processing/processing4.git
synced 2026-04-20 19:24:26 +02:00
Refactored / Simplified App Build script
This commit is contained in:
@@ -13,6 +13,7 @@ plugins{
|
|||||||
}
|
}
|
||||||
|
|
||||||
group = rootProject.group
|
group = rootProject.group
|
||||||
|
version = rootProject.version
|
||||||
|
|
||||||
repositories{
|
repositories{
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
@@ -33,6 +34,8 @@ sourceSets{
|
|||||||
|
|
||||||
compose.desktop {
|
compose.desktop {
|
||||||
application {
|
application {
|
||||||
|
mainClass = "processing.app.ui.Start"
|
||||||
|
|
||||||
jvmArgs(*listOf(
|
jvmArgs(*listOf(
|
||||||
Pair("processing.version", version),
|
Pair("processing.version", version),
|
||||||
Pair("processing.revision", "1300"),
|
Pair("processing.revision", "1300"),
|
||||||
@@ -42,23 +45,16 @@ compose.desktop {
|
|||||||
Pair("processing.tutorials", "https://processing.org/tutorials/"),
|
Pair("processing.tutorials", "https://processing.org/tutorials/"),
|
||||||
).map { "-D${it.first}=${it.second}" }.toTypedArray())
|
).map { "-D${it.first}=${it.second}" }.toTypedArray())
|
||||||
|
|
||||||
mainClass = "processing.app.ui.Start"
|
|
||||||
|
|
||||||
nativeDistributions{
|
nativeDistributions{
|
||||||
modules("jdk.jdi", "java.compiler")
|
modules("jdk.jdi", "java.compiler")
|
||||||
targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb)
|
targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb)
|
||||||
packageName = "Processing"
|
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{
|
macOS{
|
||||||
bundleID = "org.processing.app"
|
bundleID = "org.processing.app"
|
||||||
iconFile = project.file("../build/macos/processing.icns")
|
iconFile = project.file("../build/macos/processing.icns")
|
||||||
infoPlist{
|
infoPlist{
|
||||||
extraKeysRawXml = plistStrings
|
extraKeysRawXml = layout.projectDirectory.file("info.plist").asFile.readText()
|
||||||
}
|
}
|
||||||
entitlementsFile.set(project.file("entitlements.plist"))
|
entitlementsFile.set(project.file("entitlements.plist"))
|
||||||
runtimeEntitlementsFile.set(project.file("entitlements.plist"))
|
runtimeEntitlementsFile.set(project.file("entitlements.plist"))
|
||||||
@@ -74,9 +70,12 @@ compose.desktop {
|
|||||||
iconFile = project.file("../build/linux/processing.png")
|
iconFile = project.file("../build/linux/processing.png")
|
||||||
// Fix fonts on some Linux distributions
|
// Fix fonts on some Linux distributions
|
||||||
jvmArgs("-Dawt.useSystemAAFontSettings=on")
|
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)
|
implementation(libs.kaml)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tasks.compileJava{
|
||||||
|
options.encoding = "UTF-8"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// LEGACY TASKS
|
// LEGACY TASKS
|
||||||
// Most of these are shims to be compatible with the old build system
|
// 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
|
// They should be removed in the future, as we work towards making things more Gradle-native
|
||||||
tasks.register<Copy>("copyCore"){
|
val composeResources = { subPath: String -> layout.buildDirectory.dir("resources-bundled/common/$subPath") }
|
||||||
val project = project(":core")
|
compose.desktop.application.nativeDistributions.appResourcesRootDir.set(composeResources("../"))
|
||||||
dependsOn(project.tasks.jar)
|
|
||||||
from(project.layout.buildDirectory.dir("libs"))
|
tasks.register<Copy>("includeCore"){
|
||||||
from(project.configurations.runtimeClasspath)
|
val core = project(":core")
|
||||||
into(layout.buildDirectory.dir("resources-bundled/common/core/library"))
|
dependsOn(core.tasks.jar)
|
||||||
|
from(core.layout.buildDirectory.dir("libs"))
|
||||||
|
from(core.configurations.runtimeClasspath)
|
||||||
|
into(composeResources("core/library"))
|
||||||
}
|
}
|
||||||
tasks.register<Copy>("copyJava"){
|
tasks.register<Copy>("includeJavaMode") {
|
||||||
val project = project(":java")
|
val java = project(":java")
|
||||||
dependsOn(project.tasks.jar)
|
dependsOn(java.tasks.jar)
|
||||||
from(project.layout.buildDirectory.dir("libs"))
|
from(java.layout.buildDirectory.dir("libs"))
|
||||||
from(project.configurations.runtimeClasspath)
|
from(java.configurations.runtimeClasspath)
|
||||||
into(layout.buildDirectory.dir("resources-bundled/common/modes/java/mode"))
|
into(composeResources("modes/java/mode"))
|
||||||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||||
}
|
}
|
||||||
tasks.register<Download>("downloadJDK") {
|
tasks.register<Download>("includeJdk") {
|
||||||
val os: OperatingSystem = DefaultNativePlatform.getCurrentOperatingSystem()
|
val os = DefaultNativePlatform.getCurrentOperatingSystem()
|
||||||
val arch: String = System.getProperty("os.arch").let { originalArch ->
|
val arch = when (System.getProperty("os.arch")) {
|
||||||
when (originalArch) {
|
"amd64", "x86_64" -> "x64"
|
||||||
"amd64" -> "x64"
|
else -> System.getProperty("os.arch")
|
||||||
"x86_64" -> "x64"
|
|
||||||
else -> originalArch
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
val platform = when {
|
val platform = when {
|
||||||
os.isWindows -> "windows"
|
os.isWindows -> "windows"
|
||||||
os.isMacOsX -> "mac"
|
os.isMacOsX -> "mac"
|
||||||
@@ -147,73 +150,65 @@ tasks.register<Download>("downloadJDK") {
|
|||||||
"hotspot/normal/eclipse?project=jdk")
|
"hotspot/normal/eclipse?project=jdk")
|
||||||
|
|
||||||
val extension = if (os.isWindows) "zip" else "tar.gz"
|
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)
|
overwrite(false)
|
||||||
}
|
doLast {
|
||||||
tasks.register<Copy>("unzipJDK") {
|
copy {
|
||||||
val dl = tasks.findByPath("downloadJDK") as Download
|
val archive = if (os.isWindows) { zipTree(jdk) } else { tarTree(jdk) }
|
||||||
dependsOn(dl)
|
from(archive){ eachFile{ permissions{ unix("755") } } }
|
||||||
|
into(composeResources(""))
|
||||||
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<Copy>("copyShared"){
|
|
||||||
from("../build/shared/")
|
|
||||||
into(layout.buildDirectory.dir("resources-bundled/common"))
|
|
||||||
}
|
|
||||||
tasks.register<Download>("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<Copy>("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<Download>("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<Copy>("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"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
into(layout.buildDirectory.dir("resources-bundled/common/modes/java/examples"))
|
|
||||||
}
|
}
|
||||||
tasks.register<Copy>("copyJavaMode"){
|
tasks.register<Copy>("includeSharedAssets"){
|
||||||
dependsOn("unzipExamples","unzipWebsiteExamples")
|
from("../build/shared/")
|
||||||
dependsOn(project(":java").tasks.named("extraResources"))
|
into(composeResources(""))
|
||||||
from(project(":java").layout.buildDirectory.dir("resources-bundled"))
|
}
|
||||||
into(layout.buildDirectory.dir("resources-bundled"))
|
tasks.register<Download>("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<Download>("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<Copy>("includeJavaModeResources") {
|
||||||
|
val java = project(":java")
|
||||||
|
dependsOn(java.tasks.named("extraResources"))
|
||||||
|
from(java.layout.buildDirectory.dir("resources-bundled"))
|
||||||
|
into(composeResources("../"))
|
||||||
}
|
}
|
||||||
tasks.register<Copy>("renameWindres") {
|
tasks.register<Copy>("renameWindres") {
|
||||||
dependsOn("copyJavaMode", "copyShared", "unzipJDK")
|
dependsOn("includeSharedAssets","includeJavaModeResources")
|
||||||
val dir = layout.buildDirectory.dir("resources-bundled/common/modes/java/application/launch4j/bin/")
|
val dir = composeResources("modes/java/application/launch4j/bin/")
|
||||||
val os: OperatingSystem = DefaultNativePlatform.getCurrentOperatingSystem()
|
val os = DefaultNativePlatform.getCurrentOperatingSystem()
|
||||||
val platform = when {
|
val platform = when {
|
||||||
os.isWindows -> "windows"
|
os.isWindows -> "windows"
|
||||||
os.isMacOsX -> "macos"
|
os.isMacOsX -> "macos"
|
||||||
@@ -227,103 +222,16 @@ tasks.register<Copy>("renameWindres") {
|
|||||||
into(dir)
|
into(dir)
|
||||||
}
|
}
|
||||||
afterEvaluate {
|
afterEvaluate {
|
||||||
tasks.findByName("prepareAppResources")?.dependsOn("unzipJDK","copyShared", "copyCore", "copyJava", "unzipExamples","renameWindres", "copyJavaMode")
|
tasks.named("prepareAppResources").configure {
|
||||||
tasks.register("setExecutablePermissions") {
|
dependsOn(
|
||||||
description = "Sets executable permissions on binaries in Processing.app resources"
|
"includeCore",
|
||||||
group = "compose desktop"
|
"includeJavaMode",
|
||||||
|
"includeJdk",
|
||||||
doLast {
|
"includeSharedAssets",
|
||||||
val resourcesPath = layout.buildDirectory.dir("compose/binaries")
|
"includeProcessingExamples",
|
||||||
fileTree(resourcesPath) {
|
"includeProcessingWebsiteExamples",
|
||||||
include("**/resources/**/bin/**")
|
"includeJavaModeResources",
|
||||||
include("**/resources/**/*.sh")
|
"renameWindres"
|
||||||
include("**/resources/**/*.dylib")
|
)
|
||||||
include("**/resources/**/*.so")
|
|
||||||
include("**/resources/**/*.exe")
|
|
||||||
}.forEach { file ->
|
|
||||||
if (file.isFile) {
|
|
||||||
file.setExecutable(true, false)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
tasks.findByName("createDistributable")?.finalizedBy("setExecutablePermissions")
|
}
|
||||||
}
|
|
||||||
|
|
||||||
val plistStrings: String
|
|
||||||
get() = """
|
|
||||||
<key>CFBundleURLTypes</key>
|
|
||||||
<array>
|
|
||||||
<dict>
|
|
||||||
<key>CFBundleURLName</key>
|
|
||||||
<string>org.processing.app</string>
|
|
||||||
<key>CFBundleURLSchemes</key>
|
|
||||||
<array>
|
|
||||||
<string>pde</string>
|
|
||||||
</array>
|
|
||||||
</dict>
|
|
||||||
</array>
|
|
||||||
<key>CFBundleDocumentTypes</key>
|
|
||||||
<array>
|
|
||||||
<dict>
|
|
||||||
<key>CFBundleTypeExtensions</key>
|
|
||||||
<array>
|
|
||||||
<string>pde</string>
|
|
||||||
</array>
|
|
||||||
<key>LSTypeIsPackage</key>
|
|
||||||
<false/>
|
|
||||||
<key>CFBundleTypeIconFile</key>
|
|
||||||
<string>macos/pde.icns</string>
|
|
||||||
<key>CFBundleTypeName</key>
|
|
||||||
<string>Processing Source Code</string>
|
|
||||||
<key>CFBundleTypeRole</key>
|
|
||||||
<string>Editor</string>
|
|
||||||
</dict>
|
|
||||||
<dict>
|
|
||||||
<key>CFBundleTypeExtensions</key>
|
|
||||||
<array>
|
|
||||||
<string>pyde</string>
|
|
||||||
</array>
|
|
||||||
<key>LSTypeIsPackage</key>
|
|
||||||
<false/>
|
|
||||||
<key>CFBundleTypeIconFile</key>
|
|
||||||
<string>macos/pde.icns</string>
|
|
||||||
<key>CFBundleTypeName</key>
|
|
||||||
<string>Processing Python Source Code</string>
|
|
||||||
<key>CFBundleTypeRole</key>
|
|
||||||
<string>Editor</string>
|
|
||||||
</dict>
|
|
||||||
<dict>
|
|
||||||
<key>CFBundleTypeExtensions</key>
|
|
||||||
<array>
|
|
||||||
<string>pdez</string>
|
|
||||||
</array>
|
|
||||||
<key>LSTypeIsPackage</key>
|
|
||||||
<false/>
|
|
||||||
<key>CFBundleTypeIconFile</key>
|
|
||||||
<string>macos/pdez.icns</string>
|
|
||||||
<key>CFBundleTypeName</key>
|
|
||||||
<string>Processing Sketch Bundle</string>
|
|
||||||
<key>CFBundleTypeRole</key>
|
|
||||||
<string>Editor</string>
|
|
||||||
</dict>
|
|
||||||
<dict>
|
|
||||||
<key>CFBundleTypeExtensions</key>
|
|
||||||
<array>
|
|
||||||
<string>pdex</string>
|
|
||||||
</array>
|
|
||||||
<key>LSTypeIsPackage</key>
|
|
||||||
<false/>
|
|
||||||
<key>CFBundleTypeIconFile</key>
|
|
||||||
<string>macos/pdex.icns</string>
|
|
||||||
<key>CFBundleTypeName</key>
|
|
||||||
<string>Processing Contribution Bundle</string>
|
|
||||||
<key>CFBundleTypeRole</key>
|
|
||||||
<string>Viewer</string>
|
|
||||||
</dict>
|
|
||||||
</array>
|
|
||||||
<key>NSCameraUsageDescription</key>
|
|
||||||
<string>The sketch you're running needs access to your video camera.</string>
|
|
||||||
<key>NSMicrophoneUsageDescription</key>
|
|
||||||
<string>The sketch you're running needs access to your microphone.</string>
|
|
||||||
"""
|
|
||||||
74
app/info.plist
Normal file
74
app/info.plist
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
<key>CFBundleURLTypes</key>
|
||||||
|
<array>
|
||||||
|
<dict>
|
||||||
|
<key>CFBundleURLName</key>
|
||||||
|
<string>org.processing.app</string>
|
||||||
|
<key>CFBundleURLSchemes</key>
|
||||||
|
<array>
|
||||||
|
<string>pde</string>
|
||||||
|
</array>
|
||||||
|
</dict>
|
||||||
|
</array>
|
||||||
|
<key>CFBundleDocumentTypes</key>
|
||||||
|
<array>
|
||||||
|
<dict>
|
||||||
|
<key>CFBundleTypeExtensions</key>
|
||||||
|
<array>
|
||||||
|
<string>pde</string>
|
||||||
|
</array>
|
||||||
|
<key>LSTypeIsPackage</key>
|
||||||
|
<false/>
|
||||||
|
<key>CFBundleTypeIconFile</key>
|
||||||
|
<string>macos/pde.icns</string>
|
||||||
|
<key>CFBundleTypeName</key>
|
||||||
|
<string>Processing Source Code</string>
|
||||||
|
<key>CFBundleTypeRole</key>
|
||||||
|
<string>Editor</string>
|
||||||
|
</dict>
|
||||||
|
<dict>
|
||||||
|
<key>CFBundleTypeExtensions</key>
|
||||||
|
<array>
|
||||||
|
<string>pyde</string>
|
||||||
|
</array>
|
||||||
|
<key>LSTypeIsPackage</key>
|
||||||
|
<false/>
|
||||||
|
<key>CFBundleTypeIconFile</key>
|
||||||
|
<string>macos/pde.icns</string>
|
||||||
|
<key>CFBundleTypeName</key>
|
||||||
|
<string>Processing Python Source Code</string>
|
||||||
|
<key>CFBundleTypeRole</key>
|
||||||
|
<string>Editor</string>
|
||||||
|
</dict>
|
||||||
|
<dict>
|
||||||
|
<key>CFBundleTypeExtensions</key>
|
||||||
|
<array>
|
||||||
|
<string>pdez</string>
|
||||||
|
</array>
|
||||||
|
<key>LSTypeIsPackage</key>
|
||||||
|
<false/>
|
||||||
|
<key>CFBundleTypeIconFile</key>
|
||||||
|
<string>macos/pdez.icns</string>
|
||||||
|
<key>CFBundleTypeName</key>
|
||||||
|
<string>Processing Sketch Bundle</string>
|
||||||
|
<key>CFBundleTypeRole</key>
|
||||||
|
<string>Editor</string>
|
||||||
|
</dict>
|
||||||
|
<dict>
|
||||||
|
<key>CFBundleTypeExtensions</key>
|
||||||
|
<array>
|
||||||
|
<string>pdex</string>
|
||||||
|
</array>
|
||||||
|
<key>LSTypeIsPackage</key>
|
||||||
|
<false/>
|
||||||
|
<key>CFBundleTypeIconFile</key>
|
||||||
|
<string>macos/pdex.icns</string>
|
||||||
|
<key>CFBundleTypeName</key>
|
||||||
|
<string>Processing Contribution Bundle</string>
|
||||||
|
<key>CFBundleTypeRole</key>
|
||||||
|
<string>Viewer</string>
|
||||||
|
</dict>
|
||||||
|
</array>
|
||||||
|
<key>NSCameraUsageDescription</key>
|
||||||
|
<string>The sketch you're running needs access to your video camera.</string>
|
||||||
|
<key>NSMicrophoneUsageDescription</key>
|
||||||
|
<string>The sketch you're running needs access to your microphone.</string>
|
||||||
Reference in New Issue
Block a user