Skip to content

Commit

Permalink
Move plugin install command to top level and make generic
Browse files Browse the repository at this point in the history
  • Loading branch information
robsyme committed Dec 6, 2024
1 parent c6d5999 commit 0dc8999
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 32 deletions.
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ publish-index:

#
# Install plugin to ~/.nextflow/plugins using Gradle
# Usage: make install-plugin [plugin=nf-hello]
#
install-plugin:
./gradlew installPlugin
ifdef plugin
./gradlew installSpecificPlugin -Pplugin=${plugin}
else
./gradlew installPlugins
endif
25 changes: 24 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,30 @@ To build and test the plugin during development, configure a local Nextflow buil
The plugin can be tested without using a local Nextflow build using the following steps:

1. Build the plugin: `make buildPlugins`
2. Copy `build/plugins/<your-plugin>` to `$HOME/.nextflow/plugins`
2. Install the plugin using one of these methods:

```bash
# Install a specific plugin (if you have added new plugins to the plugins/ directory)
make install-plugin plugin=nf-hello
# Install all available plugins
make install-plugin
```

The plugins will be installed to one of these locations, in order of precedence:
- Directory specified by `NXF_PLUGINS_DIR` environment variable
- `$NXF_HOME/plugins` if `NXF_HOME` is set
- `$HOME/.nextflow/plugins` (default location)

Alternatively, you can use Gradle commands directly:
```bash
# Install a specific plugin
./gradlew installSpecificPlugin -Pplugin=nf-hello
# Install all plugins
./gradlew installPlugins
```

3. Create a pipeline that uses your plugin and run it: `nextflow run ./my-pipeline-script.nf`

## Package, upload, and publish
Expand Down
69 changes: 69 additions & 0 deletions plugins/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,44 @@ subprojects {
}

task upload(dependsOn: [uploadPlugin] ) { }

/*
* Task to install plugin to the Nextflow plugins directory for local testing and development.
* For production deployment, see "Package, upload, and publish" section in README.md.
*/
task installPlugin(type: Copy, dependsOn: copyPluginZip) {
description = "Installs ${project.name} plugin to the Nextflow plugins directory"
group = 'Plugin Installation'

def pluginsDir = System.getenv('NXF_PLUGINS_DIR') ?:
System.getenv('NXF_HOME') ? "${System.getenv('NXF_HOME')}/plugins" :
"${System.getProperty('user.home')}/.nextflow/plugins"

// Use the subproject's name and version
def pluginZip = file("$rootProject.buildDir/plugins/${project.name}-${project.version}.zip")
def pluginDir = file("$pluginsDir/${project.name}-${project.version}")

doFirst {
println "Installing plugin ${project.name} version ${project.version} to: $pluginDir"
pluginDir.mkdirs()
}

from zipTree(pluginZip)
into pluginDir

doLast {
println "Plugin ${project.name} installed successfully!"
println "Installation location: $pluginDir"
println "Installation location determined by:"
if (System.getenv('NXF_PLUGINS_DIR')) {
println " - NXF_PLUGINS_DIR environment variable"
} else if (System.getenv('NXF_HOME')) {
println " - NXF_HOME environment variable"
} else {
println " - Default location (~/.nextflow/plugins)"
}
}
}
}

/*
Expand All @@ -176,3 +214,34 @@ task publishIndex( type: io.nextflow.gradle.tasks.GithubRepositoryPublisher ) {
githubEmail = github_commit_email
githubToken = github_access_token
}

/*
* Task to install all plugins to the Nextflow plugins directory
*/
task installPlugins() {
description = 'Installs all plugins to the Nextflow plugins directory'
group = 'Plugin Installation'

dependsOn subprojects.installPlugin
}

/*
* Task to install a specific plugin by name
* Usage: ./gradlew installPlugin -Pplugin=nf-hello
*/
task installSpecificPlugin {
description = 'Installs a specific plugin (specify with -Pplugin=plugin-name)'
group = 'Plugin Installation'

doFirst {
if (!project.hasProperty('plugin')) {
throw new GradleException("Please specify a plugin name using -Pplugin=plugin-name")
}
def pluginName = project.property('plugin')
def pluginProject = project.findProject(":plugins:${pluginName}")
if (!pluginProject) {
throw new GradleException("Plugin '${pluginName}' not found")
}
dependsOn pluginProject.installPlugin
}
}
30 changes: 0 additions & 30 deletions plugins/nf-hello/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -88,33 +88,3 @@ test {
useJUnitPlatform()
}

// Task to install the plugin to the Nextflow plugins directory
task installPlugin(type: Copy, dependsOn: copyPluginZip) {
def pluginsDir = System.getenv('NXF_PLUGINS_DIR') ?:
System.getenv('NXF_HOME') ? "${System.getenv('NXF_HOME')}/plugins" :
"${System.getProperty('user.home')}/.nextflow/plugins"

def pluginZip = file("$rootProject.buildDir/plugins/${project.name}-${project.version}.zip")
def pluginDir = file("$pluginsDir/${project.name}-${project.version}")

doFirst {
println "Installing plugin to: $pluginDir"
pluginDir.mkdirs()
}

from zipTree(pluginZip)
into pluginDir

doLast {
println "Plugin installed successfully!"
println "Installation location determined by:"
if (System.getenv('NXF_PLUGINS_DIR')) {
println " - NXF_PLUGINS_DIR environment variable"
} else if (System.getenv('NXF_HOME')) {
println " - NXF_HOME environment variable"
} else {
println " - Default location (~/.nextflow/plugins)"
}
}
}

0 comments on commit 0dc8999

Please sign in to comment.