Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
0299209
Squashed commit of the following:
Stefterv Jul 1, 2025
0d1fcc4
Added documentation and todo's
Stefterv Jul 1, 2025
4cca647
Updated error reporting
Stefterv Jul 1, 2025
1c42961
Gradle Task error printing
Stefterv Jul 1, 2025
fcb554a
Rename gradle plugin and further planning
Stefterv Jul 2, 2025
bd5aba4
Allowing libraries folder to not exist, but log instead
Stefterv Jul 2, 2025
67de82f
Removed error & out streams, has been piped directly into System
Stefterv Jul 2, 2025
e6474e1
Small tweaks and wrote motivation for Gradle Build system
Stefterv Jul 2, 2025
1762b74
Simplified Gradle Service, improved sketch logging, fixed toolbar state
Stefterv Jul 2, 2025
5409912
Improved Gradle Error logging
Stefterv Jul 2, 2025
efd03db
Fixed gradle runner issues
Stefterv Jul 2, 2025
772567c
Build system indicators, Language keys and filtering SLF4J warnings
Stefterv Jul 2, 2025
b165d0a
Add all library jars
Stefterv Jul 2, 2025
e727dbf
Support for readonly sketches
Stefterv Jul 2, 2025
24cb4f4
Improved Error reporting
Stefterv Jul 4, 2025
d7c6aeb
Also copy Untitled sketches
Stefterv Jul 4, 2025
cebc352
Snap support
Stefterv Jul 4, 2025
b709fe3
Merge branch 'gradle-runner' of https://github.com/Stefterv/processin…
Stefterv Jul 4, 2025
5729e88
Show error logs to the user
Stefterv Jul 7, 2025
a11d2ff
Logging sketches to separate stream & small refactor
Stefterv Jul 7, 2025
b64505d
Gradle Service refactor
Stefterv Jul 7, 2025
7379166
Processing Plugin tests & Refactor
Stefterv Jul 8, 2025
a36c8a3
Plugin tests bugfixes
Stefterv Jul 8, 2025
b712390
Fixed rename Windres task
Stefterv Jul 8, 2025
c55e286
Speed up gradle compilations
Stefterv Jul 8, 2025
550200c
Comments and planning
Stefterv Jul 9, 2025
f916d27
Adding a settings panel to the editor
Stefterv Jul 16, 2025
0c674ad
Initial Gradle Plugin configuration
Stefterv Jul 17, 2025
fdc43dc
Hot Reloading plugin
Stefterv Jul 17, 2025
578c287
Build on save
Stefterv Jul 18, 2025
570e9db
Automatically download jdk
Stefterv Jul 18, 2025
046a216
Merge branch 'main' into gradle-runner
Stefterv Sep 8, 2025
00e4243
Squashed commit of the following:
Stefterv Sep 8, 2025
9f7be0c
Squashed commit of the following:
Stefterv Sep 8, 2025
e0cfc91
remove the hot-reload from this plugin for now
Stefterv Sep 8, 2025
6812454
Merge branch 'gradle-runner' into gradle-runner-final
Stefterv Sep 8, 2025
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 @@ -123,4 +136,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
40 changes: 40 additions & 0 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions app/ant/processing/app/gradle/GradleService.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package processing.app.gradle;

import processing.app.Mode;
import processing.app.Sketch;
import processing.app.ui.Editor;

import java.io.PrintStream;

public class GradleService {
public GradleService(Mode mode, Editor editor) { }

public void setEnabled(boolean enabled) {}
public boolean getEnabled() { return false; }
public void prepare(){}
public void run() {}
public void export(){}
public void stop() {}
public void startService() {}
public void setSketch(Sketch sketch) {}
public void setErr(PrintStream err) {}
public void setOut(PrintStream out) {}
}
53 changes: 22 additions & 31 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import org.gradle.internal.jvm.Jvm
import org.gradle.kotlin.dsl.support.zipTo
import org.gradle.internal.os.OperatingSystem
import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform
import org.jetbrains.compose.ExperimentalComposeLibrary
import org.jetbrains.compose.desktop.application.dsl.TargetFormat
import org.jetbrains.compose.desktop.application.tasks.AbstractJPackageTask
import org.jetbrains.compose.internal.de.undercouch.gradle.tasks.download.Download
Expand Down Expand Up @@ -49,14 +51,18 @@ compose.desktop {
application {
mainClass = "processing.app.ProcessingKt"

jvmArgs(*listOf(
Pair("processing.version", rootProject.version),
Pair("processing.revision", findProperty("revision") ?: Int.MAX_VALUE),
Pair("processing.contributions.source", "https://contributions.processing.org/contribs"),
Pair("processing.download.page", "https://processing.org/download/"),
Pair("processing.download.latest", "https://processing.org/download/latest.txt"),
Pair("processing.tutorials", "https://processing.org/tutorials/"),
).map { "-D${it.first}=${it.second}" }.toTypedArray())

val variables = mapOf(
"processing.group" to (rootProject.group.takeIf { it != "" } ?: "processing"),
"processing.version" to rootProject.version,
"processing.revision" to (findProperty("revision") ?: Int.MAX_VALUE),
"processing.contributions.source" to "https://contributions.processing.org/contribs",
"processing.download.page" to "https://processing.org/download/",
"processing.download.latest" to "https://processing.org/download/latest.txt",
"processing.tutorials" to "https://processing.org/tutorials/"
)

jvmArgs(*variables.entries.map { "-D${it.key}=${it.value}" }.toTypedArray())

nativeDistributions{
modules("jdk.jdi", "java.compiler", "jdk.accessibility", "java.management.rmi", "java.scripting", "jdk.httpserver")
Expand Down Expand Up @@ -111,21 +117,22 @@ dependencies {
implementation(compose.ui)
implementation(compose.components.resources)
implementation(compose.components.uiToolingPreview)
implementation(compose.materialIconsExtended)

implementation(compose.desktop.currentOs)

implementation(libs.compottie)
implementation(libs.kaml)
implementation(libs.markdown)
implementation(libs.markdownJVM)
implementation(gradleApi())
implementation(libs.clikt)
implementation(libs.kotlinxSerializationJson)

testImplementation(kotlin("test"))
testImplementation(libs.mockitoKotlin)
testImplementation(libs.junitJupiter)
testImplementation(libs.junitJupiterParams)

implementation(libs.clikt)
implementation(libs.kotlinxSerializationJson)
}

tasks.test {
Expand Down Expand Up @@ -390,32 +397,14 @@ tasks.register<Copy>("includeJavaModeResources") {
from(java.layout.buildDirectory.dir("resources-bundled"))
into(composeResources("../"))
}
// TODO: Move to java mode
tasks.register<Copy>("renameWindres") {
dependsOn("includeSharedAssets","includeJavaModeResources")
val dir = composeResources("modes/java/application/launch4j/bin/")
val os = DefaultNativePlatform.getCurrentOperatingSystem()
val platform = when {
os.isWindows -> "windows"
os.isMacOsX -> "macos"
else -> "linux"
}
from(dir) {
include("*-$platform*")
rename("(.*)-$platform(.*)", "$1$2")
}
duplicatesStrategy = DuplicatesStrategy.INCLUDE
into(dir)
}
tasks.register("includeProcessingResources"){
dependsOn(
"includeCore",
"includeJavaMode",
"includeSharedAssets",
"includeProcessingExamples",
"includeProcessingWebsiteExamples",
"includeJavaModeResources",
"renameWindres"
"includeJavaModeResources"
)
mustRunAfter("includeJdk")
finalizedBy("signResources")
Expand Down Expand Up @@ -495,9 +484,9 @@ tasks.register("signResources"){
}
file(composeResources("Info.plist")).delete()
}
}


}
tasks.register("setExecutablePermissions") {
description = "Sets executable permissions on binaries in Processing.app resources"
group = "compose desktop"
Expand All @@ -522,6 +511,8 @@ tasks.register("setExecutablePermissions") {
afterEvaluate {
tasks.named("prepareAppResources").configure {
dependsOn("includeProcessingResources")
// Make sure all libraries are bundled in the maven repository distributed with the app
dependsOn(listOf("core","java:preprocessor", "java:gradle", "java:gradle:hotreload").map { project(":$it").tasks.named("publishAllPublicationsToAppRepository") })
}
tasks.named("createDistributable").configure {
dependsOn("includeJdk")
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/resources/defaults.txt
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,9 @@ console.temp.days = 7
console.scrollback.lines = 500
console.scrollback.chars = 40000

# run java sketches with Gradle aka the Modern Build System
run.use_gradle = false

# Any additional Java options when running.
# If you change this and can't run things, it's your own durn fault.
run.options =
Expand Down
1 change: 0 additions & 1 deletion app/src/processing/app/Language.java
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@ static public Language init() {
return instance;
}


static private String get(String key) {
LanguageBundle bundle = init().bundle;

Expand Down
2 changes: 2 additions & 0 deletions app/src/processing/app/Preferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,8 @@ static public String getSketchbookPath() {


static protected void setSketchbookPath(String path) {
// Unify path seperator for all platforms
path = path.replace(File.separatorChar, '/');
set("sketchbook.path.four", path); //$NON-NLS-1$
}
}
1 change: 1 addition & 0 deletions app/src/processing/app/Preferences.kt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ fun loadPreferences(): Properties{
}
}

// TODO: Move this to a more appropriate place
@Composable
fun watchFile(file: File): Any? {
val scope = rememberCoroutineScope()
Expand Down
2 changes: 2 additions & 0 deletions app/src/processing/app/Processing.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import com.github.ajalt.clikt.parameters.arguments.multiple
import com.github.ajalt.clikt.parameters.options.flag
import com.github.ajalt.clikt.parameters.options.help
import com.github.ajalt.clikt.parameters.options.option
import processing.app.gradle.api.Sketch
import processing.app.api.Contributions
import processing.app.api.Sketchbook
import processing.app.ui.Start
Expand Down Expand Up @@ -51,6 +52,7 @@ suspend fun main(args: Array<String>){
.subcommands(
LSP(),
LegacyCLI(args),
Sketch(),
Contributions(),
Sketchbook()
)
Expand Down
4 changes: 3 additions & 1 deletion app/src/processing/app/Sketch.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@
* Stores information about files in the current sketch.
*/
public class Sketch {
public static final String PROPERTIES_NAME = "sketch.properties";

private final Editor editor;
private final Mode mode;

Expand Down Expand Up @@ -1305,7 +1307,7 @@ static protected Settings loadProperties(File folder) throws IOException {
}
return null;
*/
return new Settings(new File(folder, "sketch.properties"));
return new Settings(new File(folder, PROPERTIES_NAME));
}


Expand Down
44 changes: 44 additions & 0 deletions app/src/processing/app/gradle/Debugger.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package processing.app.gradle

import com.sun.jdi.Bootstrap
import com.sun.jdi.VirtualMachine
import com.sun.jdi.connect.AttachingConnector
import kotlinx.coroutines.delay
import processing.app.Messages
import kotlin.time.Duration.Companion.seconds
import kotlin.time.TimeSource

class Debugger {
companion object {
suspend fun connect(port: Int?): VirtualMachine? {
try {
Messages.log("Attaching to VM $port")
val connector = Bootstrap.virtualMachineManager().allConnectors()
.firstOrNull { it.name() == "com.sun.jdi.SocketAttach" }
as AttachingConnector?
?: throw IllegalStateException("No socket attach connector found")
val args = connector.defaultArguments()
args["port"]?.setValue(port?.toString() ?: "5005")

// Try to attach the debugger, retrying if it fails
// TODO: Stop retrying after the job has been cancelled / failed
val start = TimeSource.Monotonic.markNow()
while (start.elapsedNow() < 10.seconds) {
try {
val sketch = connector.attach(args)
sketch.resume()
Messages.log("Attached to VM: ${sketch.name()}")
return sketch
} catch (e: Exception) {
Messages.log("Error while attaching to VM: ${e.message}... Retrying")
}
delay(250)
}
} catch (e: Exception) {
Messages.log("Error while attaching to VM: ${e.message}")
return null
}
return null
}
}
}
Loading
Loading