@@ -13,6 +13,7 @@ plugins{
1313}
1414
1515group = rootProject.group
16+ version = rootProject.version
1617
1718repositories{
1819 mavenCentral()
@@ -33,6 +34,8 @@ sourceSets{
3334
3435compose.desktop {
3536 application {
37+ mainClass = " processing.app.ui.Start"
38+
3639 jvmArgs(* listOf (
3740 Pair (" processing.version" , version),
3841 Pair (" processing.revision" , " 1300" ),
@@ -42,23 +45,16 @@ compose.desktop {
4245 Pair (" processing.tutorials" , " https://processing.org/tutorials/" ),
4346 ).map { " -D${it.first} =${it.second} " }.toTypedArray())
4447
45- mainClass = " processing.app.ui.Start"
46-
4748 nativeDistributions{
4849 modules(" jdk.jdi" , " java.compiler" )
4950 targetFormats(TargetFormat .Dmg , TargetFormat .Msi , TargetFormat .Deb )
5051 packageName = " Processing"
51- packageVersion = rootProject.version.toString()
52- fileAssociation(" pde" , " Processing Source Code" , " application/x-processing" )
53- fileAssociation(" pyde" , " Processing Python Source Code" , " application/x-processing" )
54- fileAssociation(" pdez" , " Processing Sketch Bundle" , " application/x-processing" )
55- fileAssociation(" pdex" , " Processing Contribution Bundle" , " application/x-processing" )
5652
5753 macOS{
5854 bundleID = " org.processing.app"
5955 iconFile = project.file(" ../build/macos/processing.icns" )
6056 infoPlist{
61- extraKeysRawXml = plistStrings
57+ extraKeysRawXml = layout.projectDirectory.file( " info.plist " ).asFile.readText()
6258 }
6359 entitlementsFile.set(project.file(" entitlements.plist" ))
6460 runtimeEntitlementsFile.set(project.file(" entitlements.plist" ))
@@ -74,9 +70,12 @@ compose.desktop {
7470 iconFile = project.file(" ../build/linux/processing.png" )
7571 // Fix fonts on some Linux distributions
7672 jvmArgs(" -Dawt.useSystemAAFontSettings=on" )
77- }
7873
79- appResourcesRootDir.set(layout.buildDirectory.dir(" resources-bundled" ))
74+ fileAssociation(" pde" , " Processing Source Code" , " application/x-processing" )
75+ fileAssociation(" pyde" , " Processing Python Source Code" , " application/x-processing" )
76+ fileAssociation(" pdez" , " Processing Sketch Bundle" , " application/x-processing" )
77+ fileAssociation(" pdex" , " Processing Contribution Bundle" , " application/x-processing" )
78+ }
8079 }
8180 }
8281}
@@ -102,34 +101,38 @@ dependencies {
102101 implementation(libs.kaml)
103102}
104103
104+ tasks.compileJava{
105+ options.encoding = " UTF-8"
106+ }
107+
108+
105109// LEGACY TASKS
106110// Most of these are shims to be compatible with the old build system
107111// 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" ))
114- }
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" ))
112+ val composeResources = { subPath: String -> layout.buildDirectory.dir(" resources-bundled/common/$subPath " ) }
113+ compose.desktop.application.nativeDistributions.appResourcesRootDir.set(composeResources(" ../" ))
114+
115+ tasks.register<Copy >(" includeCore" ){
116+ val core = project(" :core" )
117+ dependsOn(core.tasks.jar)
118+ from(core.layout.buildDirectory.dir(" libs" ))
119+ from(core.configurations.runtimeClasspath)
120+ into(composeResources(" core/library" ))
121+ }
122+ tasks.register<Copy >(" includeJavaMode" ) {
123+ val java = project(" :java" )
124+ dependsOn(java.tasks.jar)
125+ from(java.layout.buildDirectory.dir(" libs" ))
126+ from(java.configurations.runtimeClasspath)
127+ into(composeResources(" modes/java/mode" ))
121128 duplicatesStrategy = DuplicatesStrategy .EXCLUDE
122129}
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- }
130+ tasks.register<Download >(" includeJdk" ) {
131+ val os = DefaultNativePlatform .getCurrentOperatingSystem()
132+ val arch = when (System .getProperty(" os.arch" )) {
133+ " amd64" , " x86_64" -> " x64"
134+ else -> System .getProperty(" os.arch" )
131135 }
132-
133136 val platform = when {
134137 os.isWindows -> " windows"
135138 os.isMacOsX -> " mac"
@@ -147,73 +150,65 @@ tasks.register<Download>("downloadJDK") {
147150 " hotspot/normal/eclipse?project=jdk" )
148151
149152 val extension = if (os.isWindows) " zip" else " tar.gz"
150- dest(layout.buildDirectory.file(" jdk-$platform -$arch .$extension " ))
153+ val jdk = layout.buildDirectory.file(" tmp/jdk-$platform -$arch .$extension " )
154+ dest(jdk)
151155 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)
156+ doLast {
157+ copy {
158+ val archive = if (os.isWindows) { zipTree(jdk) } else { tarTree(jdk) }
159+ from(archive){ eachFile{ permissions{ unix(" 755" ) } } }
160+ into(composeResources(" " ))
161+ }
162162 }
163-
164- from(archive){ eachFile{ permissions{ unix(" 755" ) } } }
165- into(layout.buildDirectory.dir(" resources-bundled/common" ))
166163}
167- tasks.register<Copy >(" copyShared " ){
164+ tasks.register<Copy >(" includeSharedAssets " ){
168165 from(" ../build/shared/" )
169- into(layout.buildDirectory.dir( " resources-bundled/common " ))
166+ into(composeResources( " " ))
170167}
171- tasks.register<Download >(" downloadProcessingExamples" ) {
168+ tasks.register<Download >(" includeProcessingExamples" ) {
169+ val examples = layout.buildDirectory.file(" tmp/processing-examples.zip" )
172170 src(" https://github.com/processing/processing-examples/archive/refs/heads/main.zip" )
173- dest(layout.buildDirectory.file( " tmp/processing- examples.zip " ) )
171+ dest(examples)
174172 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
173+ doLast{
174+ copy{
175+ from(zipTree(examples)){ // remove top level directory
176+ exclude(" processing-examples-main/README.md" )
177+ exclude(" processing-examples-main/.github/**" )
178+ eachFile { relativePath = RelativePath (true , * relativePath.segments.drop(1 ).toTypedArray()) }
179+ includeEmptyDirs = false
180+ }
181+ into(composeResources(" /modes/java/examples" ))
182+ }
184183 }
185- into(layout.buildDirectory.dir(" resources-bundled/common/modes/java/examples" ))
186184}
187- tasks.register<Download >(" downloadProcessingWebsiteExamples" ) {
185+ tasks.register<Download >(" includeProcessingWebsiteExamples" ) {
186+ val examples = layout.buildDirectory.file(" tmp/processing-website.zip" )
188187 src(" https://github.com/processing/processing-website/archive/refs/heads/main.zip" )
189- dest(layout.buildDirectory.file( " tmp/processing-website.zip " ) )
188+ dest(examples )
190189 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"
190+ doLast{
191+ copy{
192+ from(zipTree(examples)){
193+ include(" processing-website-main/content/examples/**" )
194+ eachFile { relativePath = RelativePath (true , * relativePath.segments.drop(3 ).toTypedArray()) }
195+ includeEmptyDirs = false
196+ exclude { it.name.contains(" .es." ) || it.name == " liveSketch.js" }
197+ }
198+ into(composeResources(" modes/java/examples" ))
203199 }
204200 }
205- into(layout.buildDirectory.dir(" resources-bundled/common/modes/java/examples" ))
206201}
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 " ))
202+ tasks.register<Copy >(" includeJavaModeResources " ) {
203+ val java = project( " :java " )
204+ dependsOn(java.tasks.named(" extraResources" ))
205+ from(java.layout.buildDirectory.dir(" resources-bundled" ))
206+ into(composeResources( " ../ " ))
212207}
213208tasks.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()
209+ dependsOn(" includeSharedAssets " , " includeJavaModeResources " )
210+ val dir = composeResources( " modes/java/application/launch4j/bin/" )
211+ val os = DefaultNativePlatform .getCurrentOperatingSystem()
217212 val platform = when {
218213 os.isWindows -> " windows"
219214 os.isMacOsX -> " macos"
@@ -227,103 +222,16 @@ tasks.register<Copy>("renameWindres") {
227222 into(dir)
228223}
229224afterEvaluate {
230- tasks.findByName(" prepareAppResources" )?.dependsOn(" unzipJDK" ," copyShared" , " copyCore" , " copyJava" , " unzipExamples" ," renameWindres" , " copyJavaMode" )
231- tasks.register(" setExecutablePermissions" ) {
232- description = " Sets executable permissions on binaries in Processing.app resources"
233- group = " compose desktop"
234-
235- doLast {
236- val resourcesPath = layout.buildDirectory.dir(" compose/binaries" )
237- fileTree(resourcesPath) {
238- include(" **/resources/**/bin/**" )
239- include(" **/resources/**/*.sh" )
240- include(" **/resources/**/*.dylib" )
241- include(" **/resources/**/*.so" )
242- include(" **/resources/**/*.exe" )
243- }.forEach { file ->
244- if (file.isFile) {
245- file.setExecutable(true , false )
246- }
247- }
248- }
225+ tasks.named(" prepareAppResources" ).configure {
226+ dependsOn(
227+ " includeCore" ,
228+ " includeJavaMode" ,
229+ " includeJdk" ,
230+ " includeSharedAssets" ,
231+ " includeProcessingExamples" ,
232+ " includeProcessingWebsiteExamples" ,
233+ " includeJavaModeResources" ,
234+ " renameWindres"
235+ )
249236 }
250- 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- """
237+ }
0 commit comments