@@ -15,14 +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- }
25-
18+ version = rootProject.version
2619
2720repositories{
2821 mavenCentral()
@@ -48,17 +41,25 @@ compose.desktop {
4841 application {
4942 mainClass = " processing.app.ui.Start"
5043
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+
5153 nativeDistributions{
52- modules(" jdk.jdi" , " java.compiler" )
54+ modules(" jdk.jdi" , " java.compiler" , " jdk.accessibility " )
5355 targetFormats(TargetFormat .Dmg , TargetFormat .Msi , TargetFormat .Deb )
5456 packageName = " Processing"
55- packageVersion = rootProject.version.toString()
5657
5758 macOS{
5859 bundleID = " org.processing.app"
5960 iconFile = project.file(" ../build/macos/processing.icns" )
6061 infoPlist{
61- extraKeysRawXml = plistStrings
62+ extraKeysRawXml = layout.projectDirectory.file( " info.plist " ).asFile.readText()
6263 }
6364 entitlementsFile.set(project.file(" entitlements.plist" ))
6465 runtimeEntitlementsFile.set(project.file(" entitlements.plist" ))
@@ -74,9 +75,12 @@ compose.desktop {
7475 iconFile = project.file(" ../build/linux/processing.png" )
7576 // Fix fonts on some Linux distributions
7677 jvmArgs(" -Dawt.useSystemAAFontSettings=on" )
77- }
7878
79- 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+ }
8084 }
8185 }
8286}
@@ -102,34 +106,38 @@ dependencies {
102106 implementation(libs.kaml)
103107}
104108
109+ tasks.compileJava{
110+ options.encoding = " UTF-8"
111+ }
112+
113+
105114// LEGACY TASKS
106115// Most of these are shims to be compatible with the old build system
107116// They should be removed in the future, as we work towards making things more Gradle-native
108- tasks.register<Copy >(" copyCore" ){
109- val project = project(" :core" )
110- dependsOn(project.tasks.jar)
111- from(project.layout.buildDirectory.dir(" libs" ))
112- from(project.configurations.runtimeClasspath)
113- into(layout.buildDirectory.dir(" resources-bundled/common/core/library" ))
117+ val composeResources = { subPath: String -> layout.buildDirectory.dir(" resources-bundled/common/$subPath " ) }
118+ compose.desktop.application.nativeDistributions.appResourcesRootDir.set(composeResources(" ../" ))
119+
120+ tasks.register<Copy >(" includeCore" ){
121+ val core = project(" :core" )
122+ dependsOn(core.tasks.jar)
123+ from(core.layout.buildDirectory.dir(" libs" ))
124+ from(core.configurations.runtimeClasspath)
125+ into(composeResources(" core/library" ))
114126}
115- tasks.register<Copy >(" copyJava " ) {
116- val project = project(" :java" )
117- dependsOn(project .tasks.jar)
118- from(project .layout.buildDirectory.dir(" libs" ))
119- from(project .configurations.runtimeClasspath)
120- into(layout.buildDirectory.dir( " resources-bundled/common/ modes/java/mode" ))
127+ tasks.register<Copy >(" includeJavaMode " ) {
128+ val java = project(" :java" )
129+ dependsOn(java .tasks.jar)
130+ from(java .layout.buildDirectory.dir(" libs" ))
131+ from(java .configurations.runtimeClasspath)
132+ into(composeResources( " modes/java/mode" ))
121133 duplicatesStrategy = DuplicatesStrategy .EXCLUDE
122134}
123- tasks.register<Download >(" downloadJDK" ) {
124- val os: OperatingSystem = DefaultNativePlatform .getCurrentOperatingSystem()
125- val arch: String = System .getProperty(" os.arch" ).let { originalArch ->
126- when (originalArch) {
127- " amd64" -> " x64"
128- " x86_64" -> " x64"
129- else -> originalArch
130- }
135+ tasks.register<Download >(" includeJdk" ) {
136+ val os = DefaultNativePlatform .getCurrentOperatingSystem()
137+ val arch = when (System .getProperty(" os.arch" )) {
138+ " amd64" , " x86_64" -> " x64"
139+ else -> System .getProperty(" os.arch" )
131140 }
132-
133141 val platform = when {
134142 os.isWindows -> " windows"
135143 os.isMacOsX -> " mac"
@@ -147,73 +155,65 @@ tasks.register<Download>("downloadJDK") {
147155 " hotspot/normal/eclipse?project=jdk" )
148156
149157 val extension = if (os.isWindows) " zip" else " tar.gz"
150- dest(layout.buildDirectory.file(" jdk-$platform -$arch .$extension " ))
158+ val jdk = layout.buildDirectory.file(" tmp/jdk-$platform -$arch .$extension " )
159+ dest(jdk)
151160 overwrite(false )
152- }
153- tasks.register<Copy >(" unzipJDK" ) {
154- val dl = tasks.findByPath(" downloadJDK" ) as Download
155- dependsOn(dl)
156-
157- val os = DefaultNativePlatform .getCurrentOperatingSystem()
158- val archive = if (os.isWindows) {
159- zipTree(dl.dest)
160- } else {
161- tarTree(dl.dest)
161+ doLast {
162+ copy {
163+ val archive = if (os.isWindows) { zipTree(jdk) } else { tarTree(jdk) }
164+ from(archive){ eachFile{ permissions{ unix(" 755" ) } } }
165+ into(composeResources(" " ))
166+ }
162167 }
163-
164- from(archive){ eachFile{ permissions{ unix(" 755" ) } } }
165- into(layout.buildDirectory.dir(" resources-bundled/common" ))
166168}
167- tasks.register<Copy >(" copyShared " ){
169+ tasks.register<Copy >(" includeSharedAssets " ){
168170 from(" ../build/shared/" )
169- into(layout.buildDirectory.dir( " resources-bundled/common " ))
171+ into(composeResources( " " ))
170172}
171- tasks.register<Download >(" downloadProcessingExamples" ) {
173+ tasks.register<Download >(" includeProcessingExamples" ) {
174+ val examples = layout.buildDirectory.file(" tmp/processing-examples.zip" )
172175 src(" https://github.com/processing/processing-examples/archive/refs/heads/main.zip" )
173- dest(layout.buildDirectory.file( " tmp/processing- examples.zip " ) )
176+ dest(examples)
174177 overwrite(false )
175- }
176- tasks.register<Copy >(" unzipExamples" ) {
177- val dl = tasks.findByPath(" downloadProcessingExamples" ) as Download
178- dependsOn(dl)
179- from(zipTree(dl.dest)){ // remove top level directory
180- exclude(" processing-examples-main/README.md" )
181- exclude(" processing-examples-main/.github/**" )
182- eachFile { relativePath = RelativePath (true , * relativePath.segments.drop(1 ).toTypedArray()) }
183- includeEmptyDirs = false
178+ doLast{
179+ copy{
180+ from(zipTree(examples)){ // remove top level directory
181+ exclude(" processing-examples-main/README.md" )
182+ exclude(" processing-examples-main/.github/**" )
183+ eachFile { relativePath = RelativePath (true , * relativePath.segments.drop(1 ).toTypedArray()) }
184+ includeEmptyDirs = false
185+ }
186+ into(composeResources(" /modes/java/examples" ))
187+ }
184188 }
185- into(layout.buildDirectory.dir(" resources-bundled/common/modes/java/examples" ))
186189}
187- tasks.register<Download >(" downloadProcessingWebsiteExamples" ) {
190+ tasks.register<Download >(" includeProcessingWebsiteExamples" ) {
191+ val examples = layout.buildDirectory.file(" tmp/processing-website.zip" )
188192 src(" https://github.com/processing/processing-website/archive/refs/heads/main.zip" )
189- dest(layout.buildDirectory.file( " tmp/processing-website.zip " ) )
193+ dest(examples )
190194 overwrite(false )
191- }
192- tasks.register<Copy >(" unzipWebsiteExamples" ) {
193- val dl = tasks.findByPath(" downloadProcessingWebsiteExamples" ) as Download
194- dependsOn(dl)
195- dependsOn(" unzipExamples" )
196- print (dl.dest)
197- from(zipTree(dl.dest)){
198- include(" processing-website-main/content/examples/**" )
199- eachFile { relativePath = RelativePath (true , * relativePath.segments.drop(3 ).toTypedArray()) }
200- includeEmptyDirs = false
201- exclude {
202- it.name.contains(" .es." ) || it.name == " liveSketch.js"
195+ doLast{
196+ copy{
197+ from(zipTree(examples)){
198+ include(" processing-website-main/content/examples/**" )
199+ eachFile { relativePath = RelativePath (true , * relativePath.segments.drop(3 ).toTypedArray()) }
200+ includeEmptyDirs = false
201+ exclude { it.name.contains(" .es." ) || it.name == " liveSketch.js" }
202+ }
203+ into(composeResources(" modes/java/examples" ))
203204 }
204205 }
205- into(layout.buildDirectory.dir(" resources-bundled/common/modes/java/examples" ))
206206}
207- tasks.register<Copy >(" copyJavaMode " ) {
208- dependsOn( " unzipExamples " , " unzipWebsiteExamples " )
209- dependsOn(project( " : java" ) .tasks.named(" extraResources" ))
210- from(project( " : java" ) .layout.buildDirectory.dir(" resources-bundled" ))
211- into(layout.buildDirectory.dir( " resources-bundled " ))
207+ tasks.register<Copy >(" includeJavaModeResources " ) {
208+ val java = project( " :java " )
209+ dependsOn(java.tasks.named(" extraResources" ))
210+ from(java.layout.buildDirectory.dir(" resources-bundled" ))
211+ into(composeResources( " ../ " ))
212212}
213213tasks.register<Copy >(" renameWindres" ) {
214- dependsOn(" copyJavaMode " , " copyShared " , " unzipJDK " )
215- val dir = layout.buildDirectory.dir( " resources-bundled/common/ modes/java/application/launch4j/bin/" )
216- val os: OperatingSystem = DefaultNativePlatform .getCurrentOperatingSystem()
214+ dependsOn(" includeSharedAssets " , " includeJavaModeResources " )
215+ val dir = composeResources( " modes/java/application/launch4j/bin/" )
216+ val os = DefaultNativePlatform .getCurrentOperatingSystem()
217217 val platform = when {
218218 os.isWindows -> " windows"
219219 os.isMacOsX -> " macos"
@@ -227,7 +227,18 @@ tasks.register<Copy>("renameWindres") {
227227 into(dir)
228228}
229229afterEvaluate {
230- tasks.findByName(" prepareAppResources" )?.dependsOn(" unzipJDK" ," copyShared" , " copyCore" , " copyJava" , " unzipExamples" ," renameWindres" , " copyJavaMode" )
230+ tasks.named(" prepareAppResources" ).configure {
231+ dependsOn(
232+ " includeCore" ,
233+ " includeJavaMode" ,
234+ " includeJdk" ,
235+ " includeSharedAssets" ,
236+ " includeProcessingExamples" ,
237+ " includeProcessingWebsiteExamples" ,
238+ " includeJavaModeResources" ,
239+ " renameWindres"
240+ )
241+ }
231242 tasks.register(" setExecutablePermissions" ) {
232243 description = " Sets executable permissions on binaries in Processing.app resources"
233244 group = " compose desktop"
@@ -248,82 +259,4 @@ afterEvaluate {
248259 }
249260 }
250261 tasks.findByName(" createDistributable" )?.finalizedBy(" setExecutablePermissions" )
251- }
252-
253- val plistStrings: String
254- get() = """
255- <key>CFBundleURLTypes</key>
256- <array>
257- <dict>
258- <key>CFBundleURLName</key>
259- <string>org.processing.app</string>
260- <key>CFBundleURLSchemes</key>
261- <array>
262- <string>pde</string>
263- </array>
264- </dict>
265- </array>
266- <key>CFBundleDocumentTypes</key>
267- <array>
268- <dict>
269- <key>CFBundleTypeExtensions</key>
270- <array>
271- <string>pde</string>
272- </array>
273- <key>LSTypeIsPackage</key>
274- <false/>
275- <key>CFBundleTypeIconFile</key>
276- <string>macos/pde.icns</string>
277- <key>CFBundleTypeName</key>
278- <string>Processing Source Code</string>
279- <key>CFBundleTypeRole</key>
280- <string>Editor</string>
281- </dict>
282- <dict>
283- <key>CFBundleTypeExtensions</key>
284- <array>
285- <string>pyde</string>
286- </array>
287- <key>LSTypeIsPackage</key>
288- <false/>
289- <key>CFBundleTypeIconFile</key>
290- <string>macos/pde.icns</string>
291- <key>CFBundleTypeName</key>
292- <string>Processing Python Source Code</string>
293- <key>CFBundleTypeRole</key>
294- <string>Editor</string>
295- </dict>
296- <dict>
297- <key>CFBundleTypeExtensions</key>
298- <array>
299- <string>pdez</string>
300- </array>
301- <key>LSTypeIsPackage</key>
302- <false/>
303- <key>CFBundleTypeIconFile</key>
304- <string>macos/pdez.icns</string>
305- <key>CFBundleTypeName</key>
306- <string>Processing Sketch Bundle</string>
307- <key>CFBundleTypeRole</key>
308- <string>Editor</string>
309- </dict>
310- <dict>
311- <key>CFBundleTypeExtensions</key>
312- <array>
313- <string>pdex</string>
314- </array>
315- <key>LSTypeIsPackage</key>
316- <false/>
317- <key>CFBundleTypeIconFile</key>
318- <string>macos/pdex.icns</string>
319- <key>CFBundleTypeName</key>
320- <string>Processing Contribution Bundle</string>
321- <key>CFBundleTypeRole</key>
322- <string>Viewer</string>
323- </dict>
324- </array>
325- <key>NSCameraUsageDescription</key>
326- <string>The sketch you're running needs access to your video camera.</string>
327- <key>NSMicrophoneUsageDescription</key>
328- <string>The sketch you're running needs access to your microphone.</string>
329- """
262+ }
0 commit comments