Skip to content

Commit 3886233

Browse files
pditommasoclaude
andcommitted
Rename publish to release terminology and add comprehensive Javadoc
- Rename classes: RegistryPublishConfig -> RegistryReleaseConfig, RegistryPublishException -> RegistryReleaseException, RegistryUploadTask -> RegistryReleaseTask - Rename methods: publish() -> release() - Update API endpoint: v1/plugins/publish -> v1/plugins/release - Update form field: file -> artifact - Update variable names and comments from publish to release terminology - Add comprehensive Javadoc documentation to all registry classes and methods 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent dd143a8 commit 3886233

11 files changed

+186
-121
lines changed

src/main/groovy/io/nextflow/gradle/NextflowPlugin.groovy

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package io.nextflow.gradle
22

3-
import io.nextflow.gradle.registry.RegistryUploadTask
3+
import io.nextflow.gradle.registry.RegistryReleaseTask
44
import org.gradle.api.Plugin
55
import org.gradle.api.Project
66
import org.gradle.api.plugins.GroovyPlugin
@@ -124,26 +124,26 @@ class NextflowPlugin implements Plugin<Project> {
124124

125125
project.afterEvaluate {
126126
if (config.publishing) {
127-
// track the publish tasks
128-
def publishTasks = []
127+
// track the release tasks
128+
def releaseTasks = []
129129

130-
// add registry publish task, if configured
130+
// add registry release task, if configured
131131
if (config.publishing.registry) {
132-
// releasePluginToRegistry - publishes plugin to a plugin registry
133-
project.tasks.register('releasePluginToRegistry', RegistryUploadTask)
132+
// releasePluginToRegistry - releases plugin to a plugin registry
133+
project.tasks.register('releasePluginToRegistry', RegistryReleaseTask)
134134
project.tasks.releasePluginToRegistry.dependsOn << project.tasks.packagePlugin
135-
publishTasks << project.tasks.releasePluginToRegistry
135+
releaseTasks << project.tasks.releasePluginToRegistry
136136
}
137137

138138

139139
// finally, configure the destination-agnostic 'release' task
140-
if (!publishTasks.isEmpty()) {
141-
// releasePlugin - all the release/publishing actions
140+
if (!releaseTasks.isEmpty()) {
141+
// releasePlugin - all the release actions
142142
project.tasks.register('releasePlugin', {
143143
group = 'Nextflow Plugin'
144144
description = 'Release plugin to configured destination'
145145
})
146-
for (task in publishTasks) {
146+
for (task in releaseTasks) {
147147
project.tasks.releasePlugin.dependsOn << task
148148
}
149149
}

src/main/groovy/io/nextflow/gradle/NextflowPluginConfig.groovy

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ class NextflowPluginConfig {
5757
List<String> extensionPoints = []
5858

5959
/**
60-
* Configure how the plugin will be published (optional)
60+
* Configure how the plugin will be released (optional)
6161
*/
62-
PluginPublishConfig publishing
62+
PluginReleaseConfig publishing
6363

6464
NextflowPluginConfig(Project project) {
6565
this.project = project
@@ -89,7 +89,7 @@ class NextflowPluginConfig {
8989

9090
// initialises the 'publishing' sub-config
9191
def publishing(Closure config) {
92-
publishing = new PluginPublishConfig(project)
92+
publishing = new PluginReleaseConfig(project)
9393
project.configure(publishing, config)
9494
publishing.validate()
9595
}
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
11
package io.nextflow.gradle
22

33
import groovy.transform.CompileStatic
4-
import io.nextflow.gradle.registry.RegistryPublishConfig
4+
import io.nextflow.gradle.registry.RegistryReleaseConfig
55
import org.gradle.api.Project
66

77
/**
88
* A gradle 'extension' to hold the 'nextflowPlugin.publishing'
99
* configuration from build.gradle.
1010
*/
1111
@CompileStatic
12-
class PluginPublishConfig {
12+
class PluginReleaseConfig {
1313
private final Project project
1414

1515
/**
16-
* Configuration for publishing to a registry
16+
* Configuration for releasing to a registry
1717
*/
18-
RegistryPublishConfig registry
18+
RegistryReleaseConfig registry
1919

20-
PluginPublishConfig(Project project) {
20+
PluginReleaseConfig(Project project) {
2121
this.project = project
2222
}
2323

2424
def validate() {}
2525

2626
def registry(Closure config) {
27-
registry = new RegistryPublishConfig(project)
27+
registry = new RegistryReleaseConfig(project)
2828
project.configure(registry, config)
2929
}
3030
}

src/main/groovy/io/nextflow/gradle/registry/RegistryClient.groovy

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,38 +8,62 @@ import org.apache.http.entity.mime.MultipartEntityBuilder
88
import org.apache.http.impl.client.HttpClients
99
import org.apache.http.util.EntityUtils
1010

11+
/**
12+
* HTTP client for communicating with a Nextflow plugin registry.
13+
*
14+
* This client handles authentication and multipart form uploads
15+
* to release plugins to a registry service via REST API.
16+
*/
1117
@Slf4j
1218
@CompileStatic
1319
class RegistryClient {
1420
private final URI url
1521
private final String authToken
1622

23+
/**
24+
* Creates a new registry client.
25+
*
26+
* @param url The base URL of the registry API endpoint
27+
* @param authToken The bearer token for authentication
28+
* @throws RegistryReleaseException if authToken is null or empty
29+
*/
1730
RegistryClient(URI url, String authToken) {
1831
if (!authToken)
19-
throw new RegistryPublishException("Authentication token not specified - Provide a valid token in 'publishing.registry' configuration")
32+
throw new RegistryReleaseException("Authentication token not specified - Provide a valid token in 'publishing.registry' configuration")
2033
this.url = !url.toString().endsWith("/")
2134
? URI.create(url.toString() + "/")
2235
: url
2336
this.authToken = authToken
2437
}
2538

26-
def publish(String id, String version, File file) {
27-
def req = new HttpPost(url.resolve("v1/plugins/publish"))
39+
/**
40+
* Releases a plugin to the registry.
41+
*
42+
* Uploads the plugin zip file along with metadata to the registry
43+
* using a multipart HTTP POST request to the v1/plugins/release endpoint.
44+
*
45+
* @param id The plugin identifier/name
46+
* @param version The plugin version (must be valid semver)
47+
* @param file The plugin zip file to upload
48+
* @throws RegistryReleaseException if the upload fails or returns an error
49+
*/
50+
def release(String id, String version, File file) {
51+
def req = new HttpPost(url.resolve("v1/plugins/release"))
2852
req.addHeader("Authorization", "Bearer ${authToken}")
2953
req.setEntity(MultipartEntityBuilder.create()
3054
.addTextBody("id", id)
3155
.addTextBody("version", version)
32-
.addBinaryBody("file", file)
56+
.addBinaryBody("artifact", file)
3357
.build())
3458

3559
try (def http = HttpClients.createDefault();
3660
def rep = http.execute(req)) {
3761

3862
if (rep.statusLine.statusCode != 200) {
39-
throw new RegistryPublishException(getErrorMessage(rep))
63+
throw new RegistryReleaseException(getErrorMessage(rep))
4064
}
4165
} catch (ConnectException | UnknownHostException e) {
42-
throw new RegistryPublishException("Unable to connect to plugin repository: ${e.message}", e)
66+
throw new RegistryReleaseException("Unable to connect to plugin repository: ${e.message}", e)
4367
}
4468
}
4569

src/main/groovy/io/nextflow/gradle/registry/RegistryPublishConfig.groovy

Lines changed: 0 additions & 23 deletions
This file was deleted.

src/main/groovy/io/nextflow/gradle/registry/RegistryPublishException.groovy

Lines changed: 0 additions & 16 deletions
This file was deleted.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package io.nextflow.gradle.registry
2+
3+
import groovy.transform.CompileStatic
4+
import org.gradle.api.Project
5+
6+
/**
7+
* Configuration for releasing plugins to a registry.
8+
*
9+
* This class holds the registry URL and authentication token
10+
* needed to upload plugins to a registry service.
11+
*/
12+
@CompileStatic
13+
class RegistryReleaseConfig {
14+
private final Project project
15+
16+
/**
17+
* The registry API base URL.
18+
* Defaults to the official Nextflow registry.
19+
*/
20+
String url = 'https://registry.nextflow.io/api'
21+
22+
/**
23+
* The authentication token (bearer token) for registry access.
24+
* Required for uploading plugins to the registry.
25+
*/
26+
String authToken
27+
28+
RegistryReleaseConfig(Project project) {
29+
this.project = project
30+
}
31+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package io.nextflow.gradle.registry
2+
3+
import org.gradle.api.GradleException
4+
5+
/**
6+
* Exception thrown when plugin registry operations fail.
7+
*
8+
* This exception is used to wrap and report errors that occur
9+
* during plugin upload to a registry, including network errors,
10+
* authentication failures, and API response errors.
11+
*/
12+
class RegistryReleaseException extends GradleException{
13+
/**
14+
* Creates a new registry release exception with the given message.
15+
*
16+
* @param message The error message
17+
*/
18+
RegistryReleaseException(String message) {
19+
super(message)
20+
}
21+
22+
/**
23+
* Creates a new registry release exception with the given message and cause.
24+
*
25+
* @param message The error message
26+
* @param cause The underlying exception that caused this error
27+
*/
28+
RegistryReleaseException(String message, Throwable cause) {
29+
super(message, cause)
30+
}
31+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
package io.nextflow.gradle.registry
2+
3+
import groovy.transform.CompileStatic
4+
import io.nextflow.gradle.NextflowPluginConfig
5+
import org.gradle.api.DefaultTask
6+
import org.gradle.api.file.RegularFileProperty
7+
import org.gradle.api.tasks.InputFile
8+
import org.gradle.api.tasks.TaskAction
9+
10+
/**
11+
* Gradle task for releasing a Nextflow plugin to a registry.
12+
*
13+
* This task uploads the assembled plugin zip file to a configured registry
14+
* using the registry's REST API. The plugin zip file is sent as a multipart
15+
* form request along with the plugin ID and version metadata.
16+
*/
17+
@CompileStatic
18+
class RegistryReleaseTask extends DefaultTask {
19+
/**
20+
* The plugin zip file to be uploaded to the registry.
21+
* By default, this points to the zip file created by the packagePlugin task.
22+
*/
23+
@InputFile
24+
final RegularFileProperty zipFile
25+
26+
RegistryReleaseTask() {
27+
group = 'Nextflow Plugin'
28+
description = 'Release the assembled plugin to the registry'
29+
30+
final buildDir = project.layout.buildDirectory.get()
31+
zipFile = project.objects.fileProperty()
32+
zipFile.convention(project.provider {
33+
buildDir.file("distributions/${project.name}-${project.version}.zip")
34+
})
35+
}
36+
37+
/**
38+
* Executes the registry release task.
39+
*
40+
* This method retrieves the plugin configuration and creates a RegistryClient
41+
* to upload the plugin zip file to the configured registry endpoint.
42+
*
43+
* @throws RegistryReleaseException if the upload fails
44+
*/
45+
@TaskAction
46+
def run() {
47+
final version = project.version.toString()
48+
final plugin = project.extensions.getByType(NextflowPluginConfig)
49+
final config = plugin.publishing.registry
50+
51+
def client = new RegistryClient(new URI(config.url), config.authToken)
52+
client.release(project.name, version, project.file(zipFile))
53+
}
54+
}

src/main/groovy/io/nextflow/gradle/registry/RegistryUploadTask.groovy

Lines changed: 0 additions & 36 deletions
This file was deleted.

0 commit comments

Comments
 (0)