Small tweaks and wrote motivation for Gradle Build system

This commit is contained in:
Stef Tervelde
2025-07-02 10:29:20 +02:00
parent 67de82f18d
commit e6474e189f
6 changed files with 37 additions and 11 deletions

View File

@@ -20,10 +20,9 @@ import kotlin.io.path.writeText
// TODO: Test running examples
// TODO: Report failures to the console
// TODO: Highlight errors in the editor
// TODO: Stop running sketches if modern build system is turned off
// TODO: ---- FUTURE ----
// TODO: Improve progress tracking
// TODO: Improve progress tracking and show it in the UI
// TODO: PoC new debugger/tweak mode
// TODO: Allow for plugins to skip gradle entirely / new modes
// TODO: Add background building
@@ -196,6 +195,7 @@ class GradleService(
private fun BuildLauncher.setup(extraArguments: List<String> = listOf()) {
// TODO: Instead of shipping Processing with a build-in JDK we should download the JDK through Gradle
setJavaHome(Platform.getJavaHome())
val arguments = setupGradle()
@@ -208,6 +208,7 @@ class GradleService(
return active.value
}
fun setEnabled(active: Boolean) {
if(!active) stopActions()
this.active.value = active
}
}

View File

@@ -81,7 +81,7 @@ public class EditorConsole extends JScrollPane {
sketchOut = new PrintStream(new EditorConsoleStream(false));
sketchErr = new PrintStream(new EditorConsoleStream(true));
startTimer();
}

View File

@@ -3,8 +3,9 @@
This the Java Mode in Processing. It compiles your sketches and runs them. It is the primary mode of Processing.
## Folders
- `application` assets for exporting applications within the mode
- `generated` generated antlr code for the mode, should be moved to a proper `antlr` plugin within gradle
- `application` assets for exporting applications within the mode (Deprecated)
- `generated` generated antlr code for the mode, should be moved to a proper `antlr` plugin within gradle (Deprecated)
- `gradle` the Processing java gradle plugin
- `libraries` libraries that are available within the mode
- `lsp` gradle build system for the language server protocol, in the future we should decouple the lsp from the java mode and pde and move all relevant code here. For now it can be found in `src/.../lsp`
- `mode` legacy files for `Ant`
@@ -13,8 +14,25 @@ This the Java Mode in Processing. It compiles your sketches and runs them. It is
- `test` tests for the mode
- `theme` assets for the mode, related to autocomplete and syntax highlighting
## Future plans
- Decouple the `lsp` and `preprocessor` from the mode and move them to their own repositories
- Move the `antlr` code to a proper plugin within gradle
- Create a gradle plugin to convert `.pde` file to `.java` files
- Create a gradle based version of Java mode.
## The Modern Build system
Since 2025 work has started on creating a new internal build system for the Java Mode based on Gradle.
The goal is to simplify by leaning more on Gradle, which provides a lot of the functionality that was build before out of the box and a lot more.
### How it used to work
The build system used to be based on some parts Ant, some parts eclipse (org.eclipse.jdt.core) and a lot of custom work build up over the years.
### How it will work going forward
The modern build system is based around Gradle, the main service (GradleService) for building a sketch with Gradle is included in `app` instead of into the Java mode as future modes are most likely also based on Gradle if they use `core` in some way. Most _Modes_ should/could probably be a Gradle plugin going forward.
Breaking the build system away from the java mode will mean that we create an island of isolation when it comes to the build system, allowing contributors to work on the build system without running the editor.
Another upside is that when we publish the Gradle plugin to the Gradle Plugin repository, it will become trivial to run Processing sketches outside the PDE and improvements made to the build system will be usable for everyone.
There is now also an opportunity for creating contributions that modify the build system in more subtle ways rather than having to make a complete new mode, e.g. a compilation step for shaders or some setup tweaks to make JavaFX work out of the box.
Furthermore, this change will embed Processing more into the wider Java ecosystem, if users want to upgrade from using Processing to Java whilst still using `core` that will become possible and won't need a rewrite of what they already created.
### How to work on the modern build system
If you want to work on the build system without the PDE, open `/java/gradle/example` into a new intellij IDEA window, this is set up to compile the Processing Java plugin and run sketches standalone.
Within the editor, the gradle plugin is embedded in Processing's embedded maven repository so that Gradle can find it.

1
java/gradle/example/.idea/.name generated Normal file
View File

@@ -0,0 +1 @@
processing-gradle-plugin-demo

6
java/gradle/example/.idea/compiler.xml generated Normal file
View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<bytecodeTargetLevel target="17" />
</component>
</project>

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="ProjectRootManager" version="2" languageLevel="JDK_24" project-jdk-name="temurin-17" project-jdk-type="JavaSDK" />
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="temurin-17" project-jdk-type="JavaSDK" />
</project>