Skip to content

Commit 795d487

Browse files
authored
Fix plugin blocks incorrectly merged in v2 config parser (#7350)
Signed-off-by: Ben Sherman <bentshermann@gmail.com>
1 parent 6860022 commit 795d487

2 files changed

Lines changed: 48 additions & 2 deletions

File tree

modules/nextflow/src/main/groovy/nextflow/config/parser/v2/ConfigDsl.groovy

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,15 +321,20 @@ class ConfigDsl extends Script {
321321
}
322322

323323
private static class PluginsDsl extends ConfigBlockDsl {
324+
private Set<String> plugins = new LinkedHashSet<>()
325+
324326
PluginsDsl(ConfigDsl dsl) {
325327
super(dsl, Collections.<String>emptyList())
326328
}
327329

328330
void id(String value) {
329-
final target = dsl.getTarget()
330-
final plugins = (Set) target.computeIfAbsent('plugins', (k) -> new LinkedHashSet<>())
331331
plugins.add(value)
332332
}
333+
334+
@Override
335+
void apply() {
336+
dsl.getTarget().put('plugins', plugins)
337+
}
333338
}
334339

335340
private static class ProcessDsl extends ConfigBlockDsl {

modules/nextflow/src/test/groovy/nextflow/config/parser/v2/ConfigParserV2Test.groovy

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,47 @@ class ConfigParserV2Test extends Specification {
8181
config.process.cpus == 1
8282
}
8383

84+
def 'should resolve multiple plugins block by replacement' () {
85+
given:
86+
def folder = Files.createTempDirectory('test')
87+
def main = folder.resolve('nextflow.config')
88+
def snippet = folder.resolve('other.config')
89+
90+
snippet.text = '''
91+
plugins {
92+
id 'nf-boost'
93+
id 'nf-schema@2.5.1'
94+
}
95+
'''
96+
97+
when:
98+
main.text = """
99+
includeConfig 'other.config'
100+
101+
plugins {
102+
id 'nf-schema@2.6.1'
103+
}
104+
"""
105+
def config = new ConfigParserV2().parse(main)
106+
then:
107+
config.plugins == ['nf-schema@2.6.1'] as Set
108+
109+
when:
110+
main.text = """
111+
plugins {
112+
id 'nf-schema@2.6.1'
113+
}
114+
115+
includeConfig 'other.config'
116+
"""
117+
config = new ConfigParserV2().parse(main)
118+
then:
119+
config.plugins == ['nf-boost', 'nf-schema@2.5.1'] as Set
120+
121+
cleanup:
122+
folder?.deleteDir()
123+
}
124+
84125
def 'should parse composed config files' () {
85126

86127
given:

0 commit comments

Comments
 (0)