|
| 1 | +# ADR: Plugin Specification Generation Task |
| 2 | + |
| 3 | +## Context |
| 4 | + |
| 5 | +Nextflow plugins require a machine-readable specification file that describes their capabilities and extension points. The `GenerateSpecTask` automates the generation of this specification file (`spec.json`) using Nextflow's built-in tooling. |
| 6 | + |
| 7 | +## Implementation |
| 8 | + |
| 9 | +### Task Type |
| 10 | +- **Extends**: `JavaExec` (not a standard task) |
| 11 | +- **Rationale**: Must execute Java code from Nextflow core library to generate the specification |
| 12 | +- **Location**: `src/main/groovy/io/nextflow/gradle/GenerateSpecTask.groovy:34` |
| 13 | + |
| 14 | +### What Runs |
| 15 | + |
| 16 | +The task executes the Java class `nextflow.plugin.spec.PluginSpecWriter` from Nextflow core: |
| 17 | + |
| 18 | +```groovy |
| 19 | +getMainClass().set('nextflow.plugin.spec.PluginSpecWriter') |
| 20 | +``` |
| 21 | + |
| 22 | +**Arguments**: `[specFile path] + [list of extension point class names]` |
| 23 | + |
| 24 | +Example: `/path/to/spec.json com.example.MyExecutor com.example.MyTraceObserver` |
| 25 | + |
| 26 | +### Nextflow Dependency |
| 27 | + |
| 28 | +**Minimum Version**: Nextflow **25.09.0** |
| 29 | +- Versions >= 25.09.0: Executes `PluginSpecWriter` to generate full specification |
| 30 | +- Versions < 25.09.0: Creates empty spec file for backward compatibility |
| 31 | + |
| 32 | +**Dependency Resolution**: Uses dedicated `specFile` source set and configuration |
| 33 | + |
| 34 | +```groovy |
| 35 | +configurations.create('specFile') |
| 36 | +sourceSets.create('specFile') { |
| 37 | + compileClasspath += configurations.specFile |
| 38 | + runtimeClasspath += configurations.specFile |
| 39 | +} |
| 40 | +``` |
| 41 | + |
| 42 | +**Classpath includes**: |
| 43 | +- `io.nextflow:nextflow:${nextflowVersion}` - provides PluginSpecWriter class |
| 44 | +- Plugin's own JAR file - provides extension point classes for introspection |
| 45 | + |
| 46 | +### Output Format & Location |
| 47 | + |
| 48 | +**Format**: JSON file |
| 49 | +**Path**: `build/resources/main/META-INF/spec.json` |
| 50 | +**Packaging**: Included in plugin JAR at `META-INF/spec.json` |
| 51 | + |
| 52 | +The specification describes plugin structure and capabilities for Nextflow's plugin system to discover. |
| 53 | + |
| 54 | +### Task Configuration |
| 55 | + |
| 56 | +**Inputs**: |
| 57 | +- `extensionPoints`: List of fully qualified class names implementing Nextflow extension points |
| 58 | + |
| 59 | +**Outputs**: |
| 60 | +- `specFile`: The generated JSON specification |
| 61 | + |
| 62 | +**Execution order**: |
| 63 | +1. Compile plugin classes (`jar`) |
| 64 | +2. Compile specFile source set (`compileSpecFileGroovy`) |
| 65 | +3. Execute `buildSpec` task |
| 66 | + |
| 67 | +### Version Detection Logic |
| 68 | + |
| 69 | +Simple integer parsing of `major.minor.patch` format: |
| 70 | +- Splits on first two dots |
| 71 | +- Compares: `major >= 25 && minor >= 9` |
| 72 | +- Handles edge suffixes: `25.09.0-edge` → supported |
| 73 | + |
| 74 | +## Decision |
| 75 | + |
| 76 | +Generate plugin specification using Nextflow's own tooling rather than custom implementation to ensure: |
| 77 | +- Compatibility with Nextflow's plugin system evolution |
| 78 | +- Correct introspection of extension point capabilities |
| 79 | +- Consistency across plugin ecosystem |
| 80 | + |
| 81 | +## Consequences |
| 82 | + |
| 83 | +**Positive**: |
| 84 | +- Delegates specification format to Nextflow core |
| 85 | +- Automatic compatibility with Nextflow's plugin discovery |
| 86 | +- Empty file fallback maintains compatibility with older Nextflow versions |
| 87 | + |
| 88 | +**Negative**: |
| 89 | +- Requires JavaExec complexity instead of simple file generation |
| 90 | +- Circular dependency: needs compiled plugin JAR before generating spec |
| 91 | +- Hard version cutoff at 25.09.0 (no graceful degradation between this version) |
0 commit comments