This is a Gradle plugin for building Nextflow plugins.
It sets up default dependencies required for integration with Nextflow, and adds some custom gradle tasks to help build and publish your Nextflow plugin.
Apply and configure this plugin in your build.gradle file, for example:
plugins {
id 'io.nextflow.nextflow-plugin' version '1.0.0-beta.12'
}
dependencies {
// (optional) put any library dependencies here
}
// plugin version
version = '0.0.1'
nextflowPlugin {
// minimum nextflow version
nextflowVersion = '25.04.0'
provider = 'Example Inc'
description = 'My example plugin'
className = 'com.example.ExamplePlugin'
extensionPoints = [
'com.example.ExampleObserver',
'com.example.ExampleFunctions'
]
}The nextflowPlugin block supports the following configuration options:
nextflowVersion(required) - Specifies the minimum Nextflow version required by the pluginclassName(required) - The fully qualified name of the main plugin classprovider(required) - The plugin provider/author namedescription(optional) - A short description of the pluginrequirePlugins(optional) - List of plugin dependencies that must be presentextensionPoints(optional) - List of extension point class names provided by the pluginuseDefaultDependencies(optional, default:true) - Whether to automatically add default dependencies required for Nextflow plugin developmentgenerateSpec(optional, default:true) - Whether to generate a plugin spec file during the build. Set tofalseto skip spec file generation
The registry block is optional and supports several configuration methods:
Option 1: Explicit configuration
registry {
url = 'https://registry.nextflow.io/api'
apiKey = 'your-api-key'
}Option 2: Using project properties
Define npr.apiUrl and npr.apiKey in your local gradle.properties OR $HOME/.gradle/gradle.properties:
npr.apiUrl=https://registry.nextflow.io/api
npr.apiKey=your-api-keyOption 3: Using environment variables Export environment variables in your shell:
export NPR_API_URL=https://registry.nextflow.io/api
export NPR_API_KEY=your-api-keyThe configuration precedence is: explicit values → project properties → environment variables → defaults.
This will add some useful tasks to your Gradle build:
assemble- Compile the Nextflow plugin code and assemble it into a zip fileinstallPlugin- Copy the assembled plugin into your local Nextflow plugins dirreleasePlugin- Release the assembled plugin to the plugin registry (always available)releasePluginToRegistry- Release the plugin to the configured registry (always available)
You should also ensure that your project's settings.gradle declares the plugin name, eg:
rootProject.name = '<YOUR-PLUGIN-NAME>'By default, the plugin automatically adds several dependencies required for Nextflow plugin development. You can disable this behavior by setting useDefaultDependencies = false in your plugin configuration.
When useDefaultDependencies is true (default), the following dependencies are automatically added:
Compile-time dependencies (compileOnly):
io.nextflow:nextflow:${nextflowVersion}- Core Nextflow classesorg.slf4j:slf4j-api:1.7.10- Logging APIorg.pf4j:pf4j:3.4.1- Plugin framework
Test dependencies (testImplementation):
org.apache.groovy:groovy- Groovy language supportio.nextflow:nextflow:${nextflowVersion}- Nextflow runtime for testingorg.spockframework:spock-core:2.3-groovy-4.0- Spock testing frameworkorg.spockframework:spock-junit4:2.3-groovy-4.0- Spock JUnit4 integration
Test runtime dependencies:
org.objenesis:objenesis:3.4- Object instantiation librarynet.bytebuddy:byte-buddy:1.14.17- Code generation library
Test fixtures:
testFixtures("io.nextflow:nextflow:${nextflowVersion}")- Nextflow test utilitiestestFixtures("io.nextflow:nf-commons:${nextflowVersion}")- Common test utilities
To disable default dependencies and manage them manually:
nextflowPlugin {
nextflowVersion = '25.04.0'
provider = 'Example Inc'
className = 'com.example.ExamplePlugin'
useDefaultDependencies = false
// Add your own dependencies in the dependencies block
}
dependencies {
// Your custom dependencies here
compileOnly 'io.nextflow:nextflow:25.04.0'
// etc...
}Follow these steps to migrate an existing Nextflow plugin:
- If your project uses a
pluginsdir, move itssrcdir to the project root - Make sure your plugin sources are now in
src/main/groovyorsrc/main/java - Replace any gradle build files with the configuration described above
See nextflow-io/nf-hello#21 for an example
This section is only relevant if you want to make changes to this Gradle plugin itself, and isn't needed for developing Nextflow plugins.
- Checkout this project and install it to your local maven repo:
./gradlew publishToMavenLocal - In your Nextflow plugin project, add this to the
settings.gradle:
pluginManagement {
repositories {
mavenLocal()
gradlePluginPortal()
}
}- Apply the configuration, as described above
To release this plugin include the Gradle plugins registry API keys in your gradle.properties.
Then use this command:
./gradlew publishPlugins