Skip to content

Commit 4bd0b61

Browse files
Fix false positive Process already defined error (#5894) [ci fast]
Signed-off-by: Ben Sherman <[email protected]> Signed-off-by: Paolo Di Tommaso <[email protected]> Co-authored-by: Paolo Di Tommaso <[email protected]> Signed-off-by: Paolo Di Tommaso <[email protected]>
1 parent d27df80 commit 4bd0b61

File tree

1 file changed

+29
-9
lines changed

1 file changed

+29
-9
lines changed

modules/nextflow/src/main/groovy/nextflow/script/IncludeDef.groovy

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,9 @@ class IncludeDef {
111111
// -- resolve the concrete against the current script
112112
final moduleFile = realModulePath(path).normalize()
113113
// -- load the module
114-
final moduleScript = loadModule0(moduleFile, resolveParams(ownerParams), session)
114+
final moduleScript = NF.getSyntaxParserVersion() == 'v2'
115+
? loadModuleV2(moduleFile, ownerParams, session)
116+
: loadModuleV1(moduleFile, resolveParams(ownerParams), session)
115117
// -- add it to the inclusions
116118
for( Module module : modules ) {
117119
meta.addModule(moduleScript, module.name, module.alias)
@@ -133,19 +135,37 @@ class IncludeDef {
133135
@PackageScope
134136
Path getOwnerPath() { getMeta().getScriptPath() }
135137

138+
/**
139+
* When using the strict syntax, the included script will already
140+
* have been compiled, so simply execute it to load its definitions.
141+
*
142+
* @param path The included script path
143+
* @param params The params of the including script
144+
* @param session The current workflow run
145+
*/
136146
@PackageScope
137147
@Memoized
138-
static BaseScript loadModule0(Path path, Map params, Session session) {
148+
static BaseScript loadModuleV2(Path path, Map params, Session session) {
139149
final script = ScriptMeta.getScriptByPath(path)
140-
if( script ) {
141-
script.getBinding().setParams(params)
142-
script.run()
143-
return script
144-
}
150+
if( !script )
151+
throw new IllegalStateException()
152+
script.getBinding().setParams(params)
153+
script.run()
154+
return script
155+
}
145156

157+
/**
158+
* When not using the strict syntax, compile and execute the
159+
* included script to load its definitions.
160+
*
161+
* @param path The included script path
162+
* @param params The params of the including script
163+
* @param session The current workflow run
164+
*/
165+
@PackageScope
166+
@Memoized
167+
static BaseScript loadModuleV1(Path path, Map params, Session session) {
146168
final binding = new ScriptBinding() .setParams(params)
147-
148-
// the execution of a library file has as side effect the registration of declared processes
149169
new ScriptLoaderV1(session)
150170
.setModule(true)
151171
.setBinding(binding)

0 commit comments

Comments
 (0)