Skip to content

Commit 4f2644a

Browse files
authored
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<Test>() 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
1 parent 05290b8 commit 4f2644a

File tree

4 files changed

+58
-5
lines changed

4 files changed

+58
-5
lines changed

.github/workflows/release.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,43 @@ jobs:
7474

7575
ORG_GRADLE_PROJECT_version: ${{ needs.version.outputs.version }}
7676
ORG_GRADLE_PROJECT_group: ${{ vars.GRADLE_GROUP }}
77+
78+
publish-gradle:
79+
name: Publish Processing Plugins to Gradle Plugin Portal
80+
runs-on: ubuntu-latest
81+
needs: version
82+
steps:
83+
- name: Checkout Repository
84+
uses: actions/checkout@v4
85+
86+
- name: Setup Processing
87+
uses: ./.github/actions/setup
88+
89+
- name: Publish plugins to Gradle Plugin Portal
90+
run: ./gradlew publishPlugins
91+
env:
92+
GRADLE_PUBLISH_KEY: ${{ secrets.GRADLE_PUBLISH_KEY }}
93+
GRADLE_PUBLISH_SECRET: ${{ secrets.GRADLE_PUBLISH_SECRET }}
94+
95+
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SIGNING_IN_MEMORY_KEY }}
96+
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_IN_MEMORY_KEY_PASSWORD }}
97+
98+
ORG_GRADLE_PROJECT_version: ${{ needs.version.outputs.version }}
99+
ORG_GRADLE_PROJECT_group: ${{ vars.GRADLE_GROUP }}
100+
101+
- name: Publish internal plugins to Gradle Plugin Portal
102+
run: ./gradlew -c gradle/plugins/settings.gradle.kts publishPlugins
103+
env:
104+
GRADLE_PUBLISH_KEY: ${{ secrets.GRADLE_PUBLISH_KEY }}
105+
GRADLE_PUBLISH_SECRET: ${{ secrets.GRADLE_PUBLISH_SECRET }}
106+
107+
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SIGNING_IN_MEMORY_KEY }}
108+
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_IN_MEMORY_KEY_PASSWORD }}
109+
110+
ORG_GRADLE_PROJECT_version: ${{ needs.version.outputs.version }}
111+
ORG_GRADLE_PROJECT_group: ${{ vars.GRADLE_GROUP }}
112+
ORG_GRADLE_PROJECT_publishingGroup: ${{ vars.GRADLE_GROUP }}
113+
77114
release-windows:
78115
name: (windows/${{ matrix.arch }}) Create Processing Release
79116
runs-on: ${{ matrix.os }}

gradle/plugins/library/build.gradle.kts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
plugins {
2-
`java-gradle-plugin`
2+
id("com.gradle.plugin-publish") version "2.0.0"
33
kotlin("jvm") version "2.2.20"
44
}
55

66
gradlePlugin {
7+
website = "https://processing.org/"
8+
vcsUrl = "https://github.com/processing/processing4"
79
plugins {
810
create("processing.library") {
9-
id = "org.processing.library"
11+
id = project.properties.getOrElse("publishingGroup", { "org.processing" }).toString() + ".library"
12+
displayName = "Processing Library Plugin"
13+
description = "Gradle plugin for building Processing libraries"
14+
tags = listOf("processing", "library", "dsl")
1015
implementationClass = "ProcessingLibraryPlugin"
1116
}
1217
}

java/gradle/build.gradle.kts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,20 @@ dependencies{
2121
testImplementation(libs.junit)
2222
}
2323

24-
// TODO: CI/CD for publishing the plugin to the Gradle Plugin Portal
2524
gradlePlugin{
25+
website = "https://processing.org/"
26+
vcsUrl = "https://github.com/processing/processing4"
2627
plugins{
2728
create("processing.java"){
28-
id = "org.processing.java"
29+
id = "$group.java"
30+
displayName = "Processing Plugin"
31+
description = "Gradle plugin for building Processing sketches"
32+
tags = listOf("processing", "sketch", "dsl")
2933
implementationClass = "org.processing.java.gradle.ProcessingPlugin"
3034
}
3135
}
3236
}
37+
3338
publishing{
3439
repositories{
3540
mavenLocal()
@@ -39,6 +44,11 @@ publishing{
3944
}
4045
}
4146
}
47+
// Grab the group before running tests, since the group is used in the test configuration and may be modified by the publishing configuration
48+
val testGroup = group.toString()
49+
tasks.withType<Test>().configureEach {
50+
systemProperty("project.group", testGroup)
51+
}
4252

4353
tasks.register("writeVersion") {
4454
// 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") {
4858
file.writeText("version=${project.version}")
4959
}
5060
}
61+
5162
tasks.named("processResources") {
5263
dependsOn("writeVersion")
5364
}

java/gradle/src/test/kotlin/ProcessingPluginTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class ProcessingPluginTest{
2020
val sketchFolder = directory.newFolder("sketch")
2121
directory.newFile("sketch/build.gradle.kts").writeText("""
2222
plugins {
23-
id("org.processing.java")
23+
id("${System.getProperty("project.group")}.java")
2424
}
2525
""".trimIndent())
2626
directory.newFile("sketch/settings.gradle.kts")

0 commit comments

Comments
 (0)