|
1 | | -# nf-hello plugin |
2 | | - |
| 1 | +# nf-hello plugin |
| 2 | + |
3 | 3 | This project contains a simple Nextflow plugin called `nf-hello` which provides examples of different plugin extensions: |
4 | 4 |
|
5 | 5 | - A custom trace observer that prints a message when the workflow starts and when the workflow completes |
6 | 6 | - A custom channel factory called `reverse` |
7 | 7 | - A custom operator called `goodbye` |
8 | 8 | - A custom function called `randomString` |
9 | 9 |
|
10 | | -NOTE: If you want to use this project as a starting point for a custom plugin, you must rename the `plugins/nf-hello` folder and update `settings.gradle` with your plugin name. |
| 10 | +NOTE: If you want to use this project as a starting point for a custom plugin, you must rename the `plugins/nf-hello` |
| 11 | +folder and update `settings.gradle` with your plugin name. |
11 | 12 |
|
12 | | -See the [Nextflow documentation](https://nextflow.io/docs/latest/plugins.html) for more information about developing plugins. |
| 13 | +See the [Nextflow documentation](https://nextflow.io/docs/latest/plugins.html) for more information about developing |
| 14 | +plugins. |
13 | 15 |
|
14 | 16 | ## Plugin structure |
15 | | - |
16 | | -- `settings.gradle` |
17 | | - |
18 | | - Gradle project settings. |
19 | | - |
20 | | -- `plugins/nf-hello` |
21 | | - |
22 | | - The plugin implementation base directory. |
23 | | - |
24 | | -- `plugins/nf-hello/build.gradle` |
25 | | - |
26 | | - Plugin Gradle build file. Project dependencies should be added here. |
27 | 17 |
|
28 | | -- `plugins/nf-hello/src/resources/META-INF/MANIFEST.MF` |
29 | | - |
30 | | - Manifest file defining the plugin attributes e.g. name, version, etc. The attribute `Plugin-Class` declares the plugin main class. This class should extend the base class `nextflow.plugin.BasePlugin` e.g. `nextflow.hello.HelloPlugin`. |
| 18 | +- `settings.gradle` |
31 | 19 |
|
32 | | -- `plugins/nf-hello/src/resources/META-INF/extensions.idx` |
33 | | - |
34 | | - This 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.ExtensionPoint` interface (or a sub-interface). |
| 20 | + Gradle project settings. |
35 | 21 |
|
36 | | -- `plugins/nf-hello/src/main` |
| 22 | +- `src/main` |
37 | 23 |
|
38 | | - The plugin implementation sources. |
| 24 | + The plugin implementation sources. |
39 | 25 |
|
40 | | -- `plugins/nf-hello/src/test` |
| 26 | +- `src/test` |
41 | 27 |
|
42 | | - The plugin unit tests. |
| 28 | + The plugin unit tests. |
43 | 29 |
|
44 | 30 | ## Plugin classes |
45 | 31 |
|
46 | 32 | - `HelloConfig`: shows how to handle options from the Nextflow configuration |
47 | 33 |
|
48 | | -- `HelloExtension`: shows how to create custom channel factories, operators, and fuctions that can be included into pipeline scripts |
| 34 | +- `HelloExtension`: shows how to create custom channel factories, operators, and fuctions that can be included into |
| 35 | + pipeline scripts |
49 | 36 |
|
50 | 37 | - `HelloFactory` and `HelloObserver`: shows how to react to workflow events with custom behavior |
51 | 38 |
|
52 | 39 | - `HelloPlugin`: the plugin entry point |
53 | 40 |
|
54 | | -## Unit testing |
55 | | - |
56 | | -To run your unit tests, run the following command in the project root directory (ie. where the file `settings.gradle` is located): |
| 41 | +## Building |
57 | 42 |
|
| 43 | +To compile and assemble the plugin, run the following command in the project root directory: |
58 | 44 | ```bash |
59 | | -./gradlew check |
| 45 | +make assemble |
60 | 46 | ``` |
61 | 47 |
|
62 | | -## Testing and debugging |
63 | | - |
64 | | -To build and test the plugin during development, configure a local Nextflow build with the following steps: |
| 48 | +## Unit testing |
65 | 49 |
|
66 | | -1. Clone the Nextflow repository in your computer into a sibling directory: |
67 | | - ```bash |
68 | | - git clone --depth 1 https://github.com/nextflow-io/nextflow ../nextflow |
69 | | - ``` |
70 | | - |
71 | | -2. Configure the plugin build to use the local Nextflow code: |
72 | | - ```bash |
73 | | - echo "includeBuild('../nextflow')" >> settings.gradle |
74 | | - ``` |
75 | | - |
76 | | - (Make sure to not add it more than once!) |
77 | | - |
78 | | -3. Compile the plugin alongside the Nextflow code: |
79 | | - ```bash |
80 | | - make assemble |
81 | | - ``` |
82 | | - |
83 | | -4. Run Nextflow with the plugin, using `./launch.sh` as a drop-in replacement for the `nextflow` command, and adding the option `-plugins nf-hello` to load the plugin: |
84 | | - ```bash |
85 | | - ./launch.sh run nextflow-io/hello -plugins nf-hello |
86 | | - ``` |
| 50 | +To run your unit tests, run the following command in the project root directory: |
| 51 | +```bash |
| 52 | +make test |
| 53 | +``` |
87 | 54 |
|
88 | | -## Testing without Nextflow build |
| 55 | +## Testing with Nextflow |
89 | 56 |
|
90 | | -The plugin can be tested without using a local Nextflow build using the following steps: |
| 57 | +The plugin can be tested without a local Nextflow installation: |
91 | 58 |
|
92 | | -1. Build the plugin: `make buildPlugins` |
93 | | -2. Copy `build/plugins/<your-plugin>` to `$HOME/.nextflow/plugins` |
94 | | -3. Create a pipeline that uses your plugin and run it: `nextflow run ./my-pipeline-script.nf` |
| 59 | +1. Build and install the plugin to your local Nextflow installation: `make install` |
| 60 | +2. Create a pipeline that uses your plugin and run it: `nextflow run ./my-pipeline-script.nf` |
95 | 61 |
|
96 | 62 | ## Package, upload, and publish |
97 | 63 |
|
98 | | -The project should be hosted in a GitHub repository whose name matches the name of the plugin, that is the name of the directory in the `plugins` folder (e.g. `nf-hello`). |
99 | | - |
100 | 64 | Follow these steps to package, upload and publish the plugin: |
101 | 65 |
|
102 | | -1. Create a file named `gradle.properties` in the project root containing the following attributes (this file should not be committed to Git): |
| 66 | +1. In `build.gradle` make sure that |
| 67 | + * `github.repository` matches the repository of the plugin |
| 68 | + * `github.indexUrl` points to your fork of the plugins index repository. |
| 69 | + |
| 70 | +2. Create a file named `$HOME/.gradle/gradle.properties`, where $HOME is your home directory. Add the following properties: |
103 | 71 |
|
104 | | - * `github_organization`: the GitHub organisation where the plugin repository is hosted. |
105 | | - * `github_username`: The GitHub username granting access to the plugin repository. |
106 | | - * `github_access_token`: The GitHub access token required to upload and commit changes to the plugin repository. |
107 | | - * `github_commit_email`: The email address associated with your GitHub account. |
| 72 | + * `github_username`: The GitHub username granting access to the plugin repository. |
| 73 | + * `github_access_token`: The GitHub access token required to upload and commit changes to the plugin repository. |
| 74 | + * `github_commit_email`: The email address associated with your GitHub account. |
108 | 75 |
|
109 | | -2. Use the following command to package and create a release for your plugin on GitHub: |
110 | | - ```bash |
111 | | - ./gradlew :plugins:nf-hello:upload |
112 | | - ``` |
| 76 | +3. Use the following command to package and create a release for your plugin on GitHub: `make release` |
113 | 77 |
|
114 | | -3. Create a pull request against [nextflow-io/plugins](https://github.com/nextflow-io/plugins/blob/main/plugins.json) to make the plugin accessible to Nextflow. |
| 78 | +4. Create a pull request against [nextflow-io/plugins](https://github.com/nextflow-io/plugins/blob/main/plugins.json) to |
| 79 | + make the plugin accessible to Nextflow. |
0 commit comments