Skip to content

Conversation

@Stefterv
Copy link
Collaborator

@Stefterv Stefterv commented Nov 19, 2025

This PR aims to decouple Base.getSketchbookFolder() from all its dependencies

Previously the following was necessary to set up to be able to read the sketchbook folder:

        val resources = File("../resources-bundled/common")
        if (!resources.exists()) {
            throw IllegalStateException("Resources folder not found at ${resources.absolutePath}")
        }
        System.setProperty("processing.resources.folder", resources.absolutePath)
        System.setProperty("java.awt.headless", "true")
        Base.setCommandLine()

        Preferences.init()
        Base.locateSketchbookFolder()

With this PR, one can freely read Base.getSketchbookFolder() and all of the required initialisation will happen automatically. e.g.

val folder = Base.getSketchbookFolder()

It will also clean up the double reference to Processing's language files by just including them in the resources system.
I would prefer to use java's resources going forward and try to move away from the bundled folder.

In general there would need to be a push towards cleaning up the side-effects of a lot of these files but that is very much out of scope for now and this way I can continue building on top of the existing infrastructure.

@Stefterv Stefterv marked this pull request as ready for review November 19, 2025 15:17
@Stefterv Stefterv requested a review from catilac November 19, 2025 15:17
Copy link
Collaborator

@catilac catilac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This must have been satisfying

Comment on lines +1 to +7
package processing.app

import kotlin.io.path.createTempDirectory
import kotlin.test.Test
import kotlin.test.assertEquals

class SketchbookTest {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a test a test!

@catilac catilac merged commit 023bfd2 into processing:main Nov 26, 2025
6 checks passed
@Stefterv Stefterv deleted the decouple-sketchbook branch November 27, 2025 08:01
@Stefterv Stefterv mentioned this pull request Nov 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants