From 4f2644a9a212c295967e3921365fd2df16bc4687 Mon Sep 17 00:00:00 2001 From: Stef Tervelde Date: Tue, 17 Feb 2026 16:46:38 +0100 Subject: [PATCH] Publish Processing Gradle plugins (#1405) * Publish Processing Gradle plugin Add a publish-gradle job to the release workflow to publish Processing libraries to the Gradle Plugin Portal using gradle publish with required secrets and version/group env vars. Update gradle/plugins/library/build.gradle.kts to use the com.gradle.plugin-publish plugin, provide plugin metadata (website, vcsUrl, displayName, description, tags) and make the plugin id dynamic ("$group.library"). These changes enable automated publishing of the Gradle plugin with the metadata required by the portal. * Publish plugins in release workflow * Update build.gradle.kts * Set project.group system property for tests Expose the project's group to test JVMs by configuring tasks.withType() to set systemProperty("project.group", group ?: "org.processing"). Update ProcessingPluginTest to read the plugin id from System.getProperty("project.group") instead of hardcoding the group. Also close the publishing block in build.gradle.kts. This allows tests to adapt when the project group is overridden. * Update build.gradle.kts --- .github/workflows/release.yml | 37 +++++++++++++++++++ gradle/plugins/library/build.gradle.kts | 9 ++++- java/gradle/build.gradle.kts | 15 +++++++- .../src/test/kotlin/ProcessingPluginTest.kt | 2 +- 4 files changed, 58 insertions(+), 5 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e8de46389..e21fce7a4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -74,6 +74,43 @@ jobs: ORG_GRADLE_PROJECT_version: ${{ needs.version.outputs.version }} ORG_GRADLE_PROJECT_group: ${{ vars.GRADLE_GROUP }} + + publish-gradle: + name: Publish Processing Plugins to Gradle Plugin Portal + runs-on: ubuntu-latest + needs: version + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Setup Processing + uses: ./.github/actions/setup + + - name: Publish plugins to Gradle Plugin Portal + run: ./gradlew publishPlugins + env: + GRADLE_PUBLISH_KEY: ${{ secrets.GRADLE_PUBLISH_KEY }} + GRADLE_PUBLISH_SECRET: ${{ secrets.GRADLE_PUBLISH_SECRET }} + + ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SIGNING_IN_MEMORY_KEY }} + ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_IN_MEMORY_KEY_PASSWORD }} + + ORG_GRADLE_PROJECT_version: ${{ needs.version.outputs.version }} + ORG_GRADLE_PROJECT_group: ${{ vars.GRADLE_GROUP }} + + - name: Publish internal plugins to Gradle Plugin Portal + run: ./gradlew -c gradle/plugins/settings.gradle.kts publishPlugins + env: + GRADLE_PUBLISH_KEY: ${{ secrets.GRADLE_PUBLISH_KEY }} + GRADLE_PUBLISH_SECRET: ${{ secrets.GRADLE_PUBLISH_SECRET }} + + ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SIGNING_IN_MEMORY_KEY }} + ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_IN_MEMORY_KEY_PASSWORD }} + + ORG_GRADLE_PROJECT_version: ${{ needs.version.outputs.version }} + ORG_GRADLE_PROJECT_group: ${{ vars.GRADLE_GROUP }} + ORG_GRADLE_PROJECT_publishingGroup: ${{ vars.GRADLE_GROUP }} + release-windows: name: (windows/${{ matrix.arch }}) Create Processing Release runs-on: ${{ matrix.os }} diff --git a/gradle/plugins/library/build.gradle.kts b/gradle/plugins/library/build.gradle.kts index d2707eef4..f70338b4e 100644 --- a/gradle/plugins/library/build.gradle.kts +++ b/gradle/plugins/library/build.gradle.kts @@ -1,12 +1,17 @@ plugins { - `java-gradle-plugin` + id("com.gradle.plugin-publish") version "2.0.0" kotlin("jvm") version "2.2.20" } gradlePlugin { + website = "https://processing.org/" + vcsUrl = "https://github.com/processing/processing4" plugins { create("processing.library") { - id = "org.processing.library" + id = project.properties.getOrElse("publishingGroup", { "org.processing" }).toString() + ".library" + displayName = "Processing Library Plugin" + description = "Gradle plugin for building Processing libraries" + tags = listOf("processing", "library", "dsl") implementationClass = "ProcessingLibraryPlugin" } } diff --git a/java/gradle/build.gradle.kts b/java/gradle/build.gradle.kts index b5718a890..8680c0a85 100644 --- a/java/gradle/build.gradle.kts +++ b/java/gradle/build.gradle.kts @@ -21,15 +21,20 @@ dependencies{ testImplementation(libs.junit) } -// TODO: CI/CD for publishing the plugin to the Gradle Plugin Portal gradlePlugin{ + website = "https://processing.org/" + vcsUrl = "https://github.com/processing/processing4" plugins{ create("processing.java"){ - id = "org.processing.java" + id = "$group.java" + displayName = "Processing Plugin" + description = "Gradle plugin for building Processing sketches" + tags = listOf("processing", "sketch", "dsl") implementationClass = "org.processing.java.gradle.ProcessingPlugin" } } } + publishing{ repositories{ mavenLocal() @@ -39,6 +44,11 @@ publishing{ } } } +// Grab the group before running tests, since the group is used in the test configuration and may be modified by the publishing configuration +val testGroup = group.toString() +tasks.withType().configureEach { + systemProperty("project.group", testGroup) +} tasks.register("writeVersion") { // make the version available to the plugin at runtime by writing it to a properties file in the resources directory @@ -48,6 +58,7 @@ tasks.register("writeVersion") { file.writeText("version=${project.version}") } } + tasks.named("processResources") { dependsOn("writeVersion") } \ No newline at end of file diff --git a/java/gradle/src/test/kotlin/ProcessingPluginTest.kt b/java/gradle/src/test/kotlin/ProcessingPluginTest.kt index 7ffeeecb5..c67725e99 100644 --- a/java/gradle/src/test/kotlin/ProcessingPluginTest.kt +++ b/java/gradle/src/test/kotlin/ProcessingPluginTest.kt @@ -20,7 +20,7 @@ class ProcessingPluginTest{ val sketchFolder = directory.newFolder("sketch") directory.newFile("sketch/build.gradle.kts").writeText(""" plugins { - id("org.processing.java") + id("${System.getProperty("project.group")}.java") } """.trimIndent()) directory.newFile("sketch/settings.gradle.kts")