This is a template for developing Processing libraries. This template is built and released with Gradle.
- Use this repository as a template repository. Look for a highlighted button to the top right with the words "Use this template." Select "Create a new repository" and then name your repository as something else, as you'd like.
- This repository will build as is. Feel free to test the release how-to, to get a sense of what to expect with those steps.
- Define the short name of your library as the
rootProject.nameinsettings.gradle.kts. The "short name" is the name of your library, without the domain. It will also be used to name the folder in the Processing sketchbook that holds the library files, and the release zip file. - Define the
groupandversionof your library inbuild.gradle.kts. The group is your domain, in reverse. The standard for version strings is semantic version (semver). - Add dependencies in the
dependenciesblock inbuild.gradle.kts. The sample library code uses the following remote dependency that is resolved with maven:Add your own dependencies using the same structure. After you add these dependencies, you can build with Gradle to download them to theimplementation("org.apache.commons:commons-math3:3.6.1")libsfolder, and then you will be able to import them in your code. Dependencies added to theimplementation"configuration" will be included in the release as jars. Dependencies added to thecompileOnlyconfiguration, such as Processing core, are available for compilation, but won't be included in the release as jars. If you want to import libraries released on Github using jitpack, jitpack is already included as a repository. - Develop your library within
src/main/java/. Set thepackageto your own domain and name, and set the version. Processing libraries are required to return the current installed version.
- Fill in the file
release.propertieswith information for your library. This information will be used to create the requiredlibrary.propertiesfile, done by a Gradle task. - To build the library and create the release artifacts run the Gradle task
releaseProcessingLib. This task will create areleasefolder with needed artifacts. On the right menu bar in Intellij, there is a Gradle menu. ToggleTasks>processingand double clickreleaseProcessingLib. This task has bundled the following required tasks:buildtask: this bundles a number of build tasks, including thejartask which creates a jar file. all build artifacts are in the folderbuild.- documentation build.
- creation of the
library.propertiesfile: this file is built from the properties set in therelease.propertiesfile, plus the version, in the taskwriteLibraryProperties. - within the
releaseProcessingLibtask, thereleasefolder is created, jars of the library and dependencies are copied, and thelibrary.propertiesfile is copied. Also, a zip file is made. 3.copyToLocalProcessingwill copy the contents of the release folder into the relevant folder in the sketchbook folder, a folder that Processing creates that holds your installed libraries, among other things. This installs your library into Processing, and you can test the release with your examples.
You can automatically distribute the library using GitHub Actions. Libraries are distributed in .zip format to the releases section of the GitHub repository. The trigger to execute the release workflow is pushing a git tag that starts with v. For example:
git tag v0.0.1
git push origin v0.0.1This template was created as part of the 2024 New Beginnings (pr05) Grant from the Processing Foundation, to simplify the workflows for libraries, tools, and modes, mentored by @Stefterv.
It is based on and inspired by a number of Processing library templates, including:
- https://github.com/processing/processing-library-template-gradle
- https://github.com/enkatsu/processing-library-template-gradle
- https://github.com/hamoid/processing-library-template/
I wish to thank the developers of these repositories, who generously provided guidance and time. This template has been developed in collaboration with @enkatsu.