Skip to content

Commit 115704b

Browse files
pditommasoclaude
andcommitted
Add useDefaultDependencies configuration option
- Add useDefaultDependencies boolean property to NextflowPluginConfig (defaults to true) - Refactor dependency management in NextflowPlugin to use addDefaultDependencies method - Add comprehensive unit tests for the new configuration option - Update README with detailed documentation of default dependencies and usage examples 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 2e49fa7 commit 115704b

File tree

4 files changed

+155
-24
lines changed

4 files changed

+155
-24
lines changed

README.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ The `nextflowPlugin` block supports the following configuration options:
4848
- **`description`** (optional) - A short description of the plugin
4949
- **`requirePlugins`** (optional) - List of plugin dependencies that must be present
5050
- **`extensionPoints`** (optional) - List of extension point class names provided by the plugin
51+
- **`useDefaultDependencies`** (optional, default: `true`) - Whether to automatically add default dependencies required for Nextflow plugin development
5152

5253
### Registry Configuration
5354

@@ -92,6 +93,50 @@ You should also ensure that your project's `settings.gradle` declares the plugin
9293
rootProject.name = '<YOUR-PLUGIN-NAME>'
9394
```
9495

96+
### Default Dependencies
97+
98+
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.
99+
100+
When `useDefaultDependencies` is `true` (default), the following dependencies are automatically added:
101+
102+
**Compile-time dependencies (compileOnly):**
103+
- `io.nextflow:nextflow:${nextflowVersion}` - Core Nextflow classes
104+
- `org.slf4j:slf4j-api:1.7.10` - Logging API
105+
- `org.pf4j:pf4j:3.4.1` - Plugin framework
106+
107+
**Test dependencies (testImplementation):**
108+
- `org.apache.groovy:groovy` - Groovy language support
109+
- `io.nextflow:nextflow:${nextflowVersion}` - Nextflow runtime for testing
110+
- `org.spockframework:spock-core:2.3-groovy-4.0` - Spock testing framework
111+
- `org.spockframework:spock-junit4:2.3-groovy-4.0` - Spock JUnit4 integration
112+
113+
**Test runtime dependencies:**
114+
- `org.objenesis:objenesis:3.4` - Object instantiation library
115+
- `net.bytebuddy:byte-buddy:1.14.17` - Code generation library
116+
117+
**Test fixtures:**
118+
- `testFixtures("io.nextflow:nextflow:${nextflowVersion}")` - Nextflow test utilities
119+
- `testFixtures("io.nextflow:nf-commons:${nextflowVersion}")` - Common test utilities
120+
121+
To disable default dependencies and manage them manually:
122+
123+
```gradle
124+
nextflowPlugin {
125+
nextflowVersion = '25.04.0'
126+
provider = 'Example Inc'
127+
className = 'com.example.ExamplePlugin'
128+
useDefaultDependencies = false
129+
130+
// Add your own dependencies in the dependencies block
131+
}
132+
133+
dependencies {
134+
// Your custom dependencies here
135+
compileOnly 'io.nextflow:nextflow:25.04.0'
136+
// etc...
137+
}
138+
```
139+
95140
## Migrating an existing Nextflow plugin
96141

97142
Follow these steps to migrate an existing Nextflow plugin:

src/main/groovy/io/nextflow/gradle/NextflowPlugin.groovy

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -62,30 +62,8 @@ class NextflowPlugin implements Plugin<Project> {
6262
config.validate()
6363
final nextflowVersion = config.nextflowVersion
6464

65-
project.dependencies { deps ->
66-
// required compile-time dependencies for nextflow plugins
67-
deps.compileOnly "io.nextflow:nextflow:${nextflowVersion}"
68-
deps.compileOnly "org.slf4j:slf4j-api:1.7.10"
69-
deps.compileOnly "org.pf4j:pf4j:3.4.1"
70-
71-
// see https://docs.gradle.org/4.1/userguide/dependency_management.html#sec:module_replacement
72-
deps.modules {
73-
module("commons-logging:commons-logging") { replacedBy("org.slf4j:jcl-over-slf4j") }
74-
}
75-
76-
// test-only dependencies (for writing tests)
77-
deps.testImplementation "org.apache.groovy:groovy"
78-
deps.testImplementation "io.nextflow:nextflow:${nextflowVersion}"
79-
deps.testImplementation("org.spockframework:spock-core:2.3-groovy-4.0") {
80-
exclude group: 'org.apache.groovy'
81-
}
82-
deps.testImplementation('org.spockframework:spock-junit4:2.3-groovy-4.0') {
83-
exclude group: 'org.apache.groovy'
84-
}
85-
deps.testRuntimeOnly "org.objenesis:objenesis:3.4"
86-
deps.testRuntimeOnly "net.bytebuddy:byte-buddy:1.14.17"
87-
deps.testImplementation(testFixtures("io.nextflow:nextflow:${nextflowVersion}"))
88-
deps.testImplementation(testFixtures("io.nextflow:nf-commons:${nextflowVersion}"))
65+
if (config.useDefaultDependencies) {
66+
addDefaultDependencies(project, nextflowVersion)
8967
}
9068
}
9169
// use JUnit 5 platform
@@ -136,4 +114,32 @@ class NextflowPlugin implements Plugin<Project> {
136114
}
137115
}
138116

117+
private void addDefaultDependencies(Project project, String nextflowVersion) {
118+
project.dependencies { deps ->
119+
// required compile-time dependencies for nextflow plugins
120+
deps.compileOnly "io.nextflow:nextflow:${nextflowVersion}"
121+
deps.compileOnly "org.slf4j:slf4j-api:1.7.10"
122+
deps.compileOnly "org.pf4j:pf4j:3.4.1"
123+
124+
// see https://docs.gradle.org/4.1/userguide/dependency_management.html#sec:module_replacement
125+
deps.modules {
126+
module("commons-logging:commons-logging") { replacedBy("org.slf4j:jcl-over-slf4j") }
127+
}
128+
129+
// test-only dependencies (for writing tests)
130+
deps.testImplementation "org.apache.groovy:groovy"
131+
deps.testImplementation "io.nextflow:nextflow:${nextflowVersion}"
132+
deps.testImplementation("org.spockframework:spock-core:2.3-groovy-4.0") {
133+
exclude group: 'org.apache.groovy'
134+
}
135+
deps.testImplementation('org.spockframework:spock-junit4:2.3-groovy-4.0') {
136+
exclude group: 'org.apache.groovy'
137+
}
138+
deps.testRuntimeOnly "org.objenesis:objenesis:3.4"
139+
deps.testRuntimeOnly "net.bytebuddy:byte-buddy:1.14.17"
140+
deps.testImplementation(testFixtures("io.nextflow:nextflow:${nextflowVersion}"))
141+
deps.testImplementation(testFixtures("io.nextflow:nf-commons:${nextflowVersion}"))
142+
}
143+
}
144+
139145
}

src/main/groovy/io/nextflow/gradle/NextflowPluginConfig.groovy

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import org.gradle.api.Project
1515
* nextflowVersion = '25.04.0'
1616
* publisher = 'nextflow'
1717
* className = 'com.example.ExamplePlugin'
18+
* useDefaultDependencies = false // optional, defaults to true
1819
* extensionPoints = [
1920
* 'com.example.ExampleFunctions'
2021
* ]
@@ -61,6 +62,11 @@ class NextflowPluginConfig {
6162
*/
6263
List<String> extensionPoints = []
6364

65+
/**
66+
* Whether to automatically add default dependencies (default: true)
67+
*/
68+
boolean useDefaultDependencies = true
69+
6470
/**
6571
* Configure registry publishing settings (optional)
6672
*/

src/test/groovy/io/nextflow/gradle/NextflowPluginTest.groovy

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,4 +154,78 @@ class NextflowPluginTest extends Specification {
154154
project.tasks.findByName('installPlugin') != null
155155
}
156156

157+
def "should add default dependencies when useDefaultDependencies is true"() {
158+
given:
159+
project.nextflowPlugin {
160+
description = 'A test plugin'
161+
provider = 'Test Author'
162+
className = 'com.example.TestPlugin'
163+
nextflowVersion = '24.04.0'
164+
useDefaultDependencies = true
165+
extensionPoints = ['com.example.TestExtension']
166+
}
167+
168+
when:
169+
project.evaluate()
170+
171+
then:
172+
def compileOnlyDeps = project.configurations.compileOnly.dependencies
173+
compileOnlyDeps.find { it.group == 'io.nextflow' && it.name == 'nextflow' && it.version == '24.04.0' }
174+
compileOnlyDeps.find { it.group == 'org.slf4j' && it.name == 'slf4j-api' && it.version == '1.7.10' }
175+
compileOnlyDeps.find { it.group == 'org.pf4j' && it.name == 'pf4j' && it.version == '3.4.1' }
176+
177+
and: "test dependencies should be added"
178+
def testDeps = project.configurations.testImplementation.dependencies
179+
testDeps.find { it.group == 'org.apache.groovy' && it.name == 'groovy' }
180+
testDeps.find { it.group == 'io.nextflow' && it.name == 'nextflow' && it.version == '24.04.0' }
181+
testDeps.find { it.group == 'org.spockframework' && it.name == 'spock-core' }
182+
}
183+
184+
def "should not add default dependencies when useDefaultDependencies is false"() {
185+
given:
186+
project.nextflowPlugin {
187+
description = 'A test plugin'
188+
provider = 'Test Author'
189+
className = 'com.example.TestPlugin'
190+
nextflowVersion = '24.04.0'
191+
useDefaultDependencies = false
192+
extensionPoints = ['com.example.TestExtension']
193+
}
194+
195+
when:
196+
project.evaluate()
197+
198+
then:
199+
def compileOnlyDeps = project.configurations.compileOnly.dependencies
200+
!compileOnlyDeps.find { it.group == 'io.nextflow' && it.name == 'nextflow' }
201+
!compileOnlyDeps.find { it.group == 'org.slf4j' && it.name == 'slf4j-api' }
202+
!compileOnlyDeps.find { it.group == 'org.pf4j' && it.name == 'pf4j' }
203+
204+
and: "test dependencies should not be added"
205+
def testDeps = project.configurations.testImplementation.dependencies
206+
!testDeps.find { it.group == 'org.apache.groovy' && it.name == 'groovy' }
207+
!testDeps.find { it.group == 'io.nextflow' && it.name == 'nextflow' }
208+
!testDeps.find { it.group == 'org.spockframework' && it.name == 'spock-core' }
209+
}
210+
211+
def "should add default dependencies by default when useDefaultDependencies is not specified"() {
212+
given:
213+
project.nextflowPlugin {
214+
description = 'A test plugin'
215+
provider = 'Test Author'
216+
className = 'com.example.TestPlugin'
217+
nextflowVersion = '24.04.0'
218+
extensionPoints = ['com.example.TestExtension']
219+
}
220+
221+
when:
222+
project.evaluate()
223+
224+
then:
225+
def compileOnlyDeps = project.configurations.compileOnly.dependencies
226+
compileOnlyDeps.find { it.group == 'io.nextflow' && it.name == 'nextflow' && it.version == '24.04.0' }
227+
compileOnlyDeps.find { it.group == 'org.slf4j' && it.name == 'slf4j-api' && it.version == '1.7.10' }
228+
compileOnlyDeps.find { it.group == 'org.pf4j' && it.name == 'pf4j' && it.version == '3.4.1' }
229+
}
230+
157231
}

0 commit comments

Comments
 (0)