Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Address deprecation warnings for tests and add local install gradle action #19

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

config ?= compileClasspath

ifdef module
Expand Down Expand Up @@ -53,7 +52,6 @@ assemble:

#
# generate build zips under build/plugins
# you can install the plugin copying manually these files to $HOME/.nextflow/plugins
#
buildPlugins:
./gradlew copyPluginZip
Expand All @@ -70,3 +68,14 @@ upload-plugins:

publish-index:
./gradlew plugins:publishIndex

#
# Install plugin to ~/.nextflow/plugins using Gradle
# Usage: make install-plugin [plugin=nf-hello]
#
install-plugin:
ifdef plugin
./gradlew :plugins:${plugin}:installPlugin
else
./gradlew installPlugin
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 :plugins:nf-hello:installPlugin

# Install all plugins
./gradlew installPlugin
```

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() {
Copy link
Contributor

@tom-seqera tom-seqera Dec 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gradle isn't the most intuitive, but in this case these two tasks (installPlugins and installSpecificPlugin) are actually implied by installPlugin.

The command

./gradlew installPlugin

will execute the installPlugin task on all modules which define it, and since we define the installPlugin in the submodules block, it's automatically defined on all the individual plugin modules.

To execute the task only for a specific plugin, we can explicitly state which submodule to run the task on:

./gradlew :plugins:nf-hello:installPlugin

This means we can remove both of these tasks, and update the Makefile to use the above forms.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah! I didn't know that! Thanks Tom!!

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
}
}
Comment on lines +218 to +247
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't forget to remove these

Suggested change
/*
* 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
}
}

3 changes: 3 additions & 0 deletions plugins/nf-hello/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ dependencies {
modules {
module("commons-logging:commons-logging") { replacedBy("org.slf4j:jcl-over-slf4j") }
}

// Add this line to explicitly declare the test framework launcher
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an addition to address the warning when running make test. The warning was:

./gradlew test --warning-mode all
Task :plugins:nf-hello:test
The automatic loading of test framework implementation dependencies has been deprecated. This is scheduled to be removed in Gradle 9.0. Declare the desired test framework directly on the test suite or explicitly declare the test framework implementation dependencies on the test's runtime classpath. Consult the upgrading guide for further information: https://docs.gradle.org/8.4/userguide/upgrading_version_8.html#test_framework_implementation_dependencies

}

// use JUnit 5 platform
Expand Down
Loading