@@ -15,15 +15,7 @@ plugins{
1515}
1616
1717group = rootProject.group
18- tasks.withType<JavaExec > {
19- systemProperty(" processing.version" , version)
20- systemProperty(" processing.revision" , " 1300" )
21- systemProperty(" processing.contributions.source" , " https://contributions-preview.processing.org/contribs.txt" )
22- systemProperty(" processing.download.page" , " https://processing.org/download/" )
23- systemProperty(" processing.download.latest" , " https://processing.org/download/latest.txt" )
24- systemProperty(" processing.tutorials" , " https://processing.org/tutorials/" )
25- }
26-
18+ version = rootProject.version
2719
2820repositories{
2921 mavenCentral()
@@ -49,17 +41,25 @@ compose.desktop {
4941 application {
5042 mainClass = " processing.app.ui.Start"
5143
44+ jvmArgs(* listOf (
45+ Pair (" processing.version" , version),
46+ Pair (" processing.revision" , " 1300" ),
47+ Pair (" processing.contributions.source" , " https://contributions-preview.processing.org/contribs.txt" ),
48+ Pair (" processing.download.page" , " https://processing.org/download/" ),
49+ Pair (" processing.download.latest" , " https://processing.org/download/latest.txt" ),
50+ Pair (" processing.tutorials" , " https://processing.org/tutorials/" ),
51+ ).map { " -D${it.first} =${it.second} " }.toTypedArray())
52+
5253 nativeDistributions{
5354 modules(" jdk.jdi" , " java.compiler" , " jdk.zipfs" )
5455 targetFormats(TargetFormat .Dmg , TargetFormat .Msi , TargetFormat .Deb )
5556 packageName = " Processing"
56- packageVersion = rootProject.version.toString()
5757
5858 macOS{
5959 bundleID = " org.processing.app"
6060 iconFile = project.file(" ../build/macos/processing.icns" )
6161 infoPlist{
62- extraKeysRawXml = plistStrings
62+ extraKeysRawXml = layout.projectDirectory.file( " info.plist " ).asFile.readText()
6363 }
6464 entitlementsFile.set(project.file(" entitlements.plist" ))
6565 runtimeEntitlementsFile.set(project.file(" entitlements.plist" ))
@@ -75,9 +75,12 @@ compose.desktop {
7575 iconFile = project.file(" ../build/linux/processing.png" )
7676 // Fix fonts on some Linux distributions
7777 jvmArgs(" -Dawt.useSystemAAFontSettings=on" )
78- }
7978
80- appResourcesRootDir.set(layout.buildDirectory.dir(" resources-bundled" ))
79+ fileAssociation(" pde" , " Processing Source Code" , " application/x-processing" )
80+ fileAssociation(" pyde" , " Processing Python Source Code" , " application/x-processing" )
81+ fileAssociation(" pdez" , " Processing Sketch Bundle" , " application/x-processing" )
82+ fileAssociation(" pdex" , " Processing Contribution Bundle" , " application/x-processing" )
83+ }
8184 }
8285 }
8386}
@@ -104,34 +107,38 @@ dependencies {
104107 implementation(libs.kaml)
105108}
106109
110+ tasks.compileJava{
111+ options.encoding = " UTF-8"
112+ }
113+
114+
107115// LEGACY TASKS
108116// Most of these are shims to be compatible with the old build system
109117// They should be removed in the future, as we work towards making things more Gradle-native
110- tasks.register<Copy >(" copyCore" ){
111- val project = project(" :core" )
112- dependsOn(project.tasks.jar)
113- from(project.layout.buildDirectory.dir(" libs" ))
114- from(project.configurations.runtimeClasspath)
115- into(layout.buildDirectory.dir(" resources-bundled/common/core/library" ))
116- }
117- tasks.register<Copy >(" copyJava" ){
118- val project = project(" :java" )
119- dependsOn(project.tasks.jar)
120- from(project.layout.buildDirectory.dir(" libs" ))
121- from(project.configurations.runtimeClasspath)
122- into(layout.buildDirectory.dir(" resources-bundled/common/modes/java/mode" ))
118+ val composeResources = { subPath: String -> layout.buildDirectory.dir(" resources-bundled/common/$subPath " ) }
119+ compose.desktop.application.nativeDistributions.appResourcesRootDir.set(composeResources(" ../" ))
120+
121+ tasks.register<Copy >(" includeCore" ){
122+ val core = project(" :core" )
123+ dependsOn(core.tasks.jar)
124+ from(core.layout.buildDirectory.dir(" libs" ))
125+ from(core.configurations.runtimeClasspath)
126+ into(composeResources(" core/library" ))
127+ }
128+ tasks.register<Copy >(" includeJavaMode" ) {
129+ val java = project(" :java" )
130+ dependsOn(java.tasks.jar)
131+ from(java.layout.buildDirectory.dir(" libs" ))
132+ from(java.configurations.runtimeClasspath)
133+ into(composeResources(" modes/java/mode" ))
123134 duplicatesStrategy = DuplicatesStrategy .EXCLUDE
124135}
125- tasks.register<Download >(" downloadJDK" ) {
126- val os: OperatingSystem = DefaultNativePlatform .getCurrentOperatingSystem()
127- val arch: String = System .getProperty(" os.arch" ).let { originalArch ->
128- when (originalArch) {
129- " amd64" -> " x64"
130- " x86_64" -> " x64"
131- else -> originalArch
132- }
136+ tasks.register<Download >(" includeJdk" ) {
137+ val os = DefaultNativePlatform .getCurrentOperatingSystem()
138+ val arch = when (System .getProperty(" os.arch" )) {
139+ " amd64" , " x86_64" -> " x64"
140+ else -> System .getProperty(" os.arch" )
133141 }
134-
135142 val platform = when {
136143 os.isWindows -> " windows"
137144 os.isMacOsX -> " mac"
@@ -149,73 +156,65 @@ tasks.register<Download>("downloadJDK") {
149156 " hotspot/normal/eclipse?project=jdk" )
150157
151158 val extension = if (os.isWindows) " zip" else " tar.gz"
152- dest(layout.buildDirectory.file(" jdk-$platform -$arch .$extension " ))
159+ val jdk = layout.buildDirectory.file(" tmp/jdk-$platform -$arch .$extension " )
160+ dest(jdk)
153161 overwrite(false )
154- }
155- tasks.register<Copy >(" unzipJDK" ) {
156- val dl = tasks.findByPath(" downloadJDK" ) as Download
157- dependsOn(dl)
158-
159- val os = DefaultNativePlatform .getCurrentOperatingSystem()
160- val archive = if (os.isWindows) {
161- zipTree(dl.dest)
162- } else {
163- tarTree(dl.dest)
162+ doLast {
163+ copy {
164+ val archive = if (os.isWindows) { zipTree(jdk) } else { tarTree(jdk) }
165+ from(archive){ eachFile{ permissions{ unix(" 755" ) } } }
166+ into(composeResources(" " ))
167+ }
164168 }
165-
166- from(archive){ eachFile{ permissions{ unix(" 755" ) } } }
167- into(layout.buildDirectory.dir(" resources-bundled/common" ))
168169}
169- tasks.register<Copy >(" copyShared " ){
170+ tasks.register<Copy >(" includeSharedAssets " ){
170171 from(" ../build/shared/" )
171- into(layout.buildDirectory.dir( " resources-bundled/common " ))
172+ into(composeResources( " " ))
172173}
173- tasks.register<Download >(" downloadProcessingExamples" ) {
174+ tasks.register<Download >(" includeProcessingExamples" ) {
175+ val examples = layout.buildDirectory.file(" tmp/processing-examples.zip" )
174176 src(" https://github.com/processing/processing-examples/archive/refs/heads/main.zip" )
175- dest(layout.buildDirectory.file( " tmp/processing- examples.zip " ) )
177+ dest(examples)
176178 overwrite(false )
177- }
178- tasks.register<Copy >(" unzipExamples" ) {
179- val dl = tasks.findByPath(" downloadProcessingExamples" ) as Download
180- dependsOn(dl)
181- from(zipTree(dl.dest)){ // remove top level directory
182- exclude(" processing-examples-main/README.md" )
183- exclude(" processing-examples-main/.github/**" )
184- eachFile { relativePath = RelativePath (true , * relativePath.segments.drop(1 ).toTypedArray()) }
185- includeEmptyDirs = false
179+ doLast{
180+ copy{
181+ from(zipTree(examples)){ // remove top level directory
182+ exclude(" processing-examples-main/README.md" )
183+ exclude(" processing-examples-main/.github/**" )
184+ eachFile { relativePath = RelativePath (true , * relativePath.segments.drop(1 ).toTypedArray()) }
185+ includeEmptyDirs = false
186+ }
187+ into(composeResources(" /modes/java/examples" ))
188+ }
186189 }
187- into(layout.buildDirectory.dir(" resources-bundled/common/modes/java/examples" ))
188190}
189- tasks.register<Download >(" downloadProcessingWebsiteExamples" ) {
191+ tasks.register<Download >(" includeProcessingWebsiteExamples" ) {
192+ val examples = layout.buildDirectory.file(" tmp/processing-website.zip" )
190193 src(" https://github.com/processing/processing-website/archive/refs/heads/main.zip" )
191- dest(layout.buildDirectory.file( " tmp/processing-website.zip " ) )
194+ dest(examples )
192195 overwrite(false )
193- }
194- tasks.register<Copy >(" unzipWebsiteExamples" ) {
195- val dl = tasks.findByPath(" downloadProcessingWebsiteExamples" ) as Download
196- dependsOn(dl)
197- dependsOn(" unzipExamples" )
198- print (dl.dest)
199- from(zipTree(dl.dest)){
200- include(" processing-website-main/content/examples/**" )
201- eachFile { relativePath = RelativePath (true , * relativePath.segments.drop(3 ).toTypedArray()) }
202- includeEmptyDirs = false
203- exclude {
204- it.name.contains(" .es." ) || it.name == " liveSketch.js"
196+ doLast{
197+ copy{
198+ from(zipTree(examples)){
199+ include(" processing-website-main/content/examples/**" )
200+ eachFile { relativePath = RelativePath (true , * relativePath.segments.drop(3 ).toTypedArray()) }
201+ includeEmptyDirs = false
202+ exclude { it.name.contains(" .es." ) || it.name == " liveSketch.js" }
203+ }
204+ into(composeResources(" modes/java/examples" ))
205205 }
206206 }
207- into(layout.buildDirectory.dir(" resources-bundled/common/modes/java/examples" ))
208207}
209- tasks.register<Copy >(" copyJavaMode " ) {
210- dependsOn( " unzipExamples " , " unzipWebsiteExamples " )
211- dependsOn(project( " : java" ) .tasks.named(" extraResources" ))
212- from(project( " : java" ) .layout.buildDirectory.dir(" resources-bundled" ))
213- into(layout.buildDirectory.dir( " resources-bundled " ))
208+ tasks.register<Copy >(" includeJavaModeResources " ) {
209+ val java = project( " :java " )
210+ dependsOn(java.tasks.named(" extraResources" ))
211+ from(java.layout.buildDirectory.dir(" resources-bundled" ))
212+ into(composeResources( " ../ " ))
214213}
215214tasks.register<Copy >(" renameWindres" ) {
216- dependsOn(" copyJavaMode " , " copyShared " , " unzipJDK " )
217- val dir = layout.buildDirectory.dir( " resources-bundled/common/ modes/java/application/launch4j/bin/" )
218- val os: OperatingSystem = DefaultNativePlatform .getCurrentOperatingSystem()
215+ dependsOn(" includeSharedAssets " , " includeJavaModeResources " )
216+ val dir = composeResources( " modes/java/application/launch4j/bin/" )
217+ val os = DefaultNativePlatform .getCurrentOperatingSystem()
219218 val platform = when {
220219 os.isWindows -> " windows"
221220 os.isMacOsX -> " macos"
@@ -229,103 +228,16 @@ tasks.register<Copy>("renameWindres") {
229228 into(dir)
230229}
231230afterEvaluate {
232- tasks.findByName(" prepareAppResources" )?.dependsOn(" unzipJDK" ," copyShared" , " copyCore" , " copyJava" , " unzipExamples" ," renameWindres" , " copyJavaMode" )
233- tasks.register(" setExecutablePermissions" ) {
234- description = " Sets executable permissions on binaries in Processing.app resources"
235- group = " compose desktop"
236-
237- doLast {
238- val resourcesPath = layout.buildDirectory.dir(" compose/binaries" )
239- fileTree(resourcesPath) {
240- include(" **/resources/**/bin/**" )
241- include(" **/resources/**/*.sh" )
242- include(" **/resources/**/*.dylib" )
243- include(" **/resources/**/*.so" )
244- include(" **/resources/**/*.exe" )
245- }.forEach { file ->
246- if (file.isFile) {
247- file.setExecutable(true , false )
248- }
249- }
250- }
231+ tasks.named(" prepareAppResources" ).configure {
232+ dependsOn(
233+ " includeCore" ,
234+ " includeJavaMode" ,
235+ " includeJdk" ,
236+ " includeSharedAssets" ,
237+ " includeProcessingExamples" ,
238+ " includeProcessingWebsiteExamples" ,
239+ " includeJavaModeResources" ,
240+ " renameWindres"
241+ )
251242 }
252- tasks.findByName(" createDistributable" )?.finalizedBy(" setExecutablePermissions" )
253- }
254-
255- val plistStrings: String
256- get() = """
257- <key>CFBundleURLTypes</key>
258- <array>
259- <dict>
260- <key>CFBundleURLName</key>
261- <string>org.processing.app</string>
262- <key>CFBundleURLSchemes</key>
263- <array>
264- <string>pde</string>
265- </array>
266- </dict>
267- </array>
268- <key>CFBundleDocumentTypes</key>
269- <array>
270- <dict>
271- <key>CFBundleTypeExtensions</key>
272- <array>
273- <string>pde</string>
274- </array>
275- <key>LSTypeIsPackage</key>
276- <false/>
277- <key>CFBundleTypeIconFile</key>
278- <string>macos/pde.icns</string>
279- <key>CFBundleTypeName</key>
280- <string>Processing Source Code</string>
281- <key>CFBundleTypeRole</key>
282- <string>Editor</string>
283- </dict>
284- <dict>
285- <key>CFBundleTypeExtensions</key>
286- <array>
287- <string>pyde</string>
288- </array>
289- <key>LSTypeIsPackage</key>
290- <false/>
291- <key>CFBundleTypeIconFile</key>
292- <string>macos/pde.icns</string>
293- <key>CFBundleTypeName</key>
294- <string>Processing Python Source Code</string>
295- <key>CFBundleTypeRole</key>
296- <string>Editor</string>
297- </dict>
298- <dict>
299- <key>CFBundleTypeExtensions</key>
300- <array>
301- <string>pdez</string>
302- </array>
303- <key>LSTypeIsPackage</key>
304- <false/>
305- <key>CFBundleTypeIconFile</key>
306- <string>macos/pdez.icns</string>
307- <key>CFBundleTypeName</key>
308- <string>Processing Sketch Bundle</string>
309- <key>CFBundleTypeRole</key>
310- <string>Editor</string>
311- </dict>
312- <dict>
313- <key>CFBundleTypeExtensions</key>
314- <array>
315- <string>pdex</string>
316- </array>
317- <key>LSTypeIsPackage</key>
318- <false/>
319- <key>CFBundleTypeIconFile</key>
320- <string>macos/pdex.icns</string>
321- <key>CFBundleTypeName</key>
322- <string>Processing Contribution Bundle</string>
323- <key>CFBundleTypeRole</key>
324- <string>Viewer</string>
325- </dict>
326- </array>
327- <key>NSCameraUsageDescription</key>
328- <string>The sketch you're running needs access to your video camera.</string>
329- <key>NSMicrophoneUsageDescription</key>
330- <string>The sketch you're running needs access to your microphone.</string>
331- """
243+ }
0 commit comments