Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,19 @@ gen-external-apklibs
hs_err_pid*
replay_pid*

# Maven ignores
.kotlin
.gradle
.build/
/core/build/
/build/publish/
/app/build
/java/build/
/build/reports
/java/bin
/java/libraries/svg/bin
/java/preprocessor/build
/java/lsp/build
### Gradle ###
.gradle
**/build/
Expand Down Expand Up @@ -124,4 +137,16 @@ generated/
!java/libraries/serial/library/jssc.jar
/app/windows/obj
/java/gradle/build
/core/examples/build
/java/gradle/example/.processing
/app/windows/obj
/java/android/example/build
/java/android/example/.processing
/java/gradle/example/build
/java/gradle/example/gradle/wrapper/gradle-wrapper.jar
/java/gradle/example/gradle/wrapper/gradle-wrapper.properties
/java/gradle/example/gradlew
/java/gradle/example/gradlew.bat
/java/gradle/example/.kotlin/errors
/java/gradle/hotreload/build
*.iml
10 changes: 10 additions & 0 deletions app/utils/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
plugins {
id("java")
alias(libs.plugins.mavenPublish)
}

repositories {
Expand All @@ -11,6 +12,15 @@ dependencies {
testImplementation("org.junit.jupiter:junit-jupiter")
}

publishing{
repositories{
maven {
name = "App"
url = uri(project(":app").layout.buildDirectory.dir("resources-bundled/common/repository").get().asFile.absolutePath)
}
}
}

tasks.test {
useJUnitPlatform()
}
5 changes: 5 additions & 0 deletions core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ plugins {

repositories {
mavenCentral()
maven { url = uri("https://jogamp.org/deployment/maven") }
}

sourceSets{
main{
java{
srcDirs("src")
exclude("**/*.jnilib")
}
resources{
srcDirs("src")
Expand Down Expand Up @@ -76,3 +78,6 @@ tasks.withType<Jar> {
tasks.compileJava{
options.encoding = "UTF-8"
}
tasks.javadoc{
options.encoding = "UTF-8"
}
18 changes: 10 additions & 8 deletions core/src/processing/core/PApplet.java
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,7 @@ public class PApplet implements PConstants {
protected boolean exitCalled;

// ok to be static because it's not possible to mix enabled/disabled
static protected boolean disableAWT;
static protected boolean disableAWT = System.getProperty("processing.awt.disable", "false").equals("true");;

// messages to send if attached as an external vm

Expand Down Expand Up @@ -9940,19 +9940,21 @@ static public void runSketch(final String[] args,
System.exit(1);
}

boolean external = false;
int[] location = null;
int[] editorLocation = null;
boolean external = System.getProperty("processing.external", "false").equals("true");;
int[] location = System.getProperty("processing.location", null) != null ?
parseInt(split(System.getProperty("processing.location"), ',')) : null;

int[] editorLocation = System.getProperty("processing.editor.location", null) != null ?
parseInt(split(System.getProperty("processing.editor.location"), ',')) : null;
String name = null;
int windowColor = 0;
int stopColor = 0xff808080;
boolean hideStop = false;
boolean hideStop = System.getProperty("processing.stop.hide", "false").equals("true");

int displayNum = -1; // use default
boolean present = false;
boolean fullScreen = false;
float uiScale = 0;
boolean present = System.getProperty("processing.present", "false").equals("true");
boolean fullScreen = System.getProperty("processing.fullscreen", "false").equals("true");
float uiScale = parseInt(System.getProperty("processing.uiScale", "0"), 0);

String param, value;
String folder = calcSketchPath();
Expand Down
113 changes: 113 additions & 0 deletions java/gradle/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
# Processing Gradle Plugin

This folder contains the source for the Processing Gradle plugin.
The plugin will transform any Processing sketch into a Gradle project for easy compilation and advanced features.

## Motivation

Processing was designed to be easy to start with, and the PDE (Processing Development Environment) handles most things
for you: you can write code, import libraries, run your sketch, or even export it as an executable. This works very well
for learning and for small to medium sketches, but it isn’t ideal for larger projects.

With the Processing Gradle Plugin, we want to make it possible to build more ambitious projects on top of Processing.
This is intended for users who are comfortable moving beyond the PDE, such as artists and developers working on larger
sketches, long running installations, multi sketch projects, or teams who want version control, automated builds, and
integration with standard Java tools and editors. It is optional and does not replace the PDE, but complements it for
more advanced workflows.

## What is Gradle

Gradle is a build tool commonly used in the Java ecosystem. It is responsible for tasks like compiling code, managing
dependencies, and running applications. You do not need to learn Gradle to use Processing in the P

## Usage

Add the following files to any Processing sketch alongside the `.pde` files

`build.gradle.kts`
```kotlin
plugins {
id("org.processing.java") version "4.5.3"
}
```

The version number determines which version of Processing will be used.

`settings.gradle.kts`
create the file but leave blank

This will turn the Processing sketch into a Gradle project, usable with any editor that supports Gradle.
Including the `gradle` command if installed. If you want to use your own editor, or no editor at all, use the
gradle command if installed. Find installation instructions
here: https://docs.gradle.org/current/userguide/installation.html

The plugin will add the `sketch` command to the Gradle tasks lists, so run the sketch with `gradle sketch`, this will
build and launch your sketch.

The sketch can also be bundled into a standalone app by using the `gradle export` command.
Or run in fullscreen with `gradle present`

To include libraries into your sketch add `processing.sketchbook=/path/to/sketchbook` to a `gradle.properties` file in
the same folder.

To use any kind of dependency add as a normal gradle dependency, the plugin has already automatically added the Maven
Central repository.

`build.gradle.kts`
```kotlin
plugins {
id("org.processing.java") version "4.5.3"
}

dependencies {
implementation("com.lowagie:itext:2.1.7")
}
```

To use an older version of Processing just change the plugin version:

`build.gradle.kts`
```kotlin
plugins {
id("org.processing.java") version "4.5.0"
}
```

Other gradle plugins are also supported

`build.gradle.kts`
```kotlin
plugins {
id("org.processing.java") version "4.5.3"
id("com.gradleup.shadow") version "<version>"
}
```

If you want to combine multiple sketches into a single project

`sketch-a/build.gradle.kts`
```kotlin
plugins {
id("org.processing.java") version "4.5.3"
}
```

`sketch-b/build.gradle.kts`

```kotlin
plugins {
id("org.processing.java") version "4.5.3"
}
```

`build.gradle.kts`

```kotlin
plugins {
id("org.processing.java") version "4.5.3" apply false
}
```

`settings.gradle.kts` - create the file but leave blank

Then run all sketches at once with `gradle sketch`
41 changes: 41 additions & 0 deletions java/gradle/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
plugins{
`java-gradle-plugin`
alias(libs.plugins.gradlePublish)

kotlin("jvm") version libs.versions.kotlin
}

repositories {
mavenCentral()
maven("https://jogamp.org/deployment/maven")
}

dependencies{
implementation(project(":java:preprocessor"))

implementation(libs.composeGradlePlugin)
implementation(libs.kotlinGradlePlugin)
implementation(libs.kotlinComposePlugin)

testImplementation(project(":core"))
testImplementation(libs.junit)
}

// TODO: CI/CD for publishing the plugin to the Gradle Plugin Portal
gradlePlugin{
plugins{
create("processing.java"){
id = "org.processing.java"
implementationClass = "org.processing.java.gradle.ProcessingPlugin"
}
}
}
publishing{
repositories{
mavenLocal()
maven {
name = "App"
url = uri(project(":app").layout.buildDirectory.dir("resources-bundled/common/repository").get().asFile.absolutePath)
}
}
}
28 changes: 28 additions & 0 deletions java/gradle/example/brightness.pde
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* Brightness
* by Rusty Robison.
*
* Brightness is the relative lightness or darkness of a color.
* Move the cursor vertically over each bar to alter its brightness.
*/

int barWidth = 20;
int lastBar = -1;


void setup() {
size(640, 360, P2D);
colorMode(HSB, width, 100, height);
noStroke();
background(0);
}

void draw() {
int whichBar = mouseX / barWidth;
if (whichBar != lastBar) {
int barX = whichBar * barWidth;
fill(barX, 100, mouseY);
rect(barX, 0, barWidth, height);
lastBar = whichBar;
}
}
3 changes: 3 additions & 0 deletions java/gradle/example/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
plugins{
id("org.processing.java")
}
5 changes: 5 additions & 0 deletions java/gradle/example/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
rootProject.name = "processing-gradle-plugin-demo"

pluginManagement {
includeBuild("../../../")
}
Loading