This project shows how to implement a simple Nextflow plugin named nf-hello which intercepts workflow execution events to print a message when the execution starts and on workflow completion.
The nf-hello plugin also enriches the channel object with a producer and consumer method (reverse and goodbye) which can be used in a pipeline script.
Also exposes some @FunctionS to be used in the pipeline as custom methods
NOTE: this repo uses the name nf-hello as root name. In case you want to use this repo as starting point for a custom plugin, you need at least to change settings.gradle and rename plugins/nf-hello folder.
-
settings.gradleGradle project settings.
-
plugins/nf-helloThe plugin implementation base directory.
-
plugins/nf-hello/build.gradlePlugin Gradle build file. Project dependencies should be added here.
-
plugins/nf-hello/src/resources/META-INF/MANIFEST.MFManifest file defining the plugin attributes e.g. name, version, etc. The attribute
Plugin-Classdeclares the plugin main class. This class should extend the base classnextflow.plugin.BasePlugine.g.nextflow.co2footprint.HelloPlugin. -
plugins/nf-hello/src/resources/META-INF/extensions.idxThis file declares one or more extension classes provided by the plugin. Each line should contain the fully qualified name of a Java class that implements the
org.pf4j.ExtensionPointinterface (or a sub-interface). -
plugins/nf-hello/src/mainThe plugin implementation sources.
-
plugins/nf-hello/src/testThe plugin unit tests.
-
HelloConfig: simple example how to handle configuration options provided via the Nextflow configuration file. -
HelloExtension: show how create an extension class that can be used to create custom channel factories, operation and fuctions that can be imported in the pipeline script as DSL extensions. -
CO2FootprintFactoryandCO2FootprintObserver: show how to intercept workflow runtime events and react correspondly with custom code. -
HelloPlugin: the plugin entry point.
Run the following command in the project root directory (ie. where the file settings.gradle is located):
./gradlew checkTo run and test the plugin in for development purpose, configure a local Nextflow build with the following steps:
-
Clone the Nextflow repository in your computer into a sibling directory:
git clone --depth 1 https://github.com/nextflow-io/nextflow ../nextflow
-
Configure the plugin build to use the local Nextflow code:
echo "includeBuild('../nextflow')" >> settings.gradle
(Make sure to not add it more than once!)
-
Compile the plugin alongside the Nextflow code:
make compile
-
Run Nextflow with the plugin, using
./launch.shas a drop-in replacement for thenextflowcommand, and adding the option-plugins nf-helloto load the plugin:./launch.sh run nextflow-io/hello -plugins nf-hello
The plugin can be tested without using a local Nextflow build using those steps:
- generate required artifacts with
make buildPlugins - copy build/plugins/your-plugin to
$HOME/.nextflow/plugins - create a pipeline with your plugin and see in action via
nextflow run ./my-pipeline-script.nf
The project should be hosted in a GitHub repository whose name should match the name of the plugin, that is the name of the directory in the plugins folder (e.g. nf-hello).
Follow these steps to package, upload and publish the plugin:
-
Create a file named
gradle.propertiesin the project root containing the following attributes (this file should not be committed to Git):github_organization: the GitHub organisation where the plugin repository is hosted.github_username: The GitHub username granting access to the plugin repository.github_access_token: The GitHub access token required to upload and commit changes to the plugin repository.github_commit_email: The email address associated with your GitHub account.
-
Use the following command to package and create a release for your plugin on GitHub:
./gradlew :plugins:nf-hello:upload
-
Create a pull request against nextflow-io/plugins to make the plugin accessible to Nextflow.