From 2fd3f577a7e99f432e63e61cc472ed7d6431a97d Mon Sep 17 00:00:00 2001 From: Ben Sherman Date: Wed, 25 Jun 2025 14:26:43 -0500 Subject: [PATCH] Upgrade to Groovy 5 Signed-off-by: Ben Sherman --- build.gradle | 4 ++-- modules/nextflow/build.gradle | 18 +++++++-------- .../src/main/groovy/nextflow/Session.groovy | 2 +- .../main/groovy/nextflow/cli/CmdLog.groovy | 6 +++-- .../nextflow/executor/ExecutorFactory.groovy | 4 ++-- .../nextflow/extension/CombineOp.groovy | 2 +- .../groovy/nextflow/extension/DumpOp.groovy | 6 +---- .../nextflow/extension/PublishOp.groovy | 16 +++++++------- .../groovy/nextflow/extension/SplitOp.groovy | 2 +- .../groovy/nextflow/file/DirListener.groovy | 2 +- .../nextflow/processor/PublishDir.groovy | 4 ++-- .../nextflow/processor/TaskConfig.groovy | 22 +++++++++---------- .../nextflow/processor/TaskProcessor.groovy | 2 +- .../groovy/nextflow/scm/AssetManager.groovy | 4 ++-- .../groovy/nextflow/script/IterableDef.groovy | 6 ++++- .../groovy/nextflow/script/ProcessDef.groovy | 2 +- .../nextflow/script/ScriptBinding.groovy | 9 +++++--- .../script/dsl/ProcessConfigBuilder.groovy | 6 ++--- .../script/params/v2/ProcessInputsDef.groovy | 4 ++-- .../nextflow/trace/ResourcesAggregator.groovy | 2 +- .../nextflow/util/SerializationHelper.groovy | 2 +- .../groovy/nextflow/util/ServiceName.groovy | 2 +- .../groovy/nextflow/util/SimpleAgent.groovy | 1 + .../nextflow/util/ThreadPoolHelper.groovy | 11 +++++----- .../groovy/nextflow/ast/OpXformTest.groovy | 2 +- modules/nf-commons/build.gradle | 6 ++--- .../src/main/nextflow/plugin/PluginRef.groovy | 14 +++--------- .../src/main/nextflow/util/CacheFunnel.groovy | 16 -------------- .../src/main/nextflow/util/CacheFunnel.java | 14 ++++++++++++ .../nextflow/util/CmdLineOptionMap.groovy | 7 +----- .../nextflow/plugin/PluginUpdaterTest.groovy | 2 +- modules/nf-httpfs/build.gradle | 6 ++--- modules/nf-lang/build.gradle | 2 +- modules/nf-lineage/build.gradle | 4 ++-- .../nextflow/lineage/LinExtensionImpl.groovy | 3 ++- .../main/nextflow/lineage/LinObserver.groovy | 4 ++-- .../test/nextflow/lineage/LinUtilsTest.groovy | 4 ++-- plugins/nf-amazon/build.gradle | 4 ++-- plugins/nf-azure/build.gradle | 4 ++-- plugins/nf-cloudcache/build.gradle | 4 ++-- plugins/nf-codecommit/build.gradle | 4 ++-- plugins/nf-console/build.gradle | 6 ++--- plugins/nf-google/build.gradle | 4 ++-- .../GoogleBatchMachineTypeSelector.groovy | 2 +- plugins/nf-k8s/build.gradle | 4 ++-- .../nextflow/k8s/model/PodSpecBuilder.groovy | 8 +++---- plugins/nf-tower/build.gradle | 6 ++--- plugins/nf-wave/build.gradle | 4 ++-- 48 files changed, 132 insertions(+), 141 deletions(-) delete mode 100644 modules/nf-commons/src/main/nextflow/util/CacheFunnel.groovy create mode 100644 modules/nf-commons/src/main/nextflow/util/CacheFunnel.java diff --git a/build.gradle b/build.gradle index 31d5ad9966..a930e7a3f6 100644 --- a/build.gradle +++ b/build.gradle @@ -105,8 +105,8 @@ allprojects { // Documentation required libraries groovyDoc 'org.fusesource.jansi:jansi:2.4.0' - groovyDoc "org.apache.groovy:groovy-groovydoc:4.0.30" - groovyDoc "org.apache.groovy:groovy-ant:4.0.30" + groovyDoc "org.apache.groovy:groovy-groovydoc:5.0.4" + groovyDoc "org.apache.groovy:groovy-ant:5.0.4" } test { diff --git a/modules/nextflow/build.gradle b/modules/nextflow/build.gradle index 78bff819f0..abd2ac74f5 100644 --- a/modules/nextflow/build.gradle +++ b/modules/nextflow/build.gradle @@ -25,12 +25,12 @@ dependencies { api(project(':nf-commons')) api(project(':nf-httpfs')) api(project(':nf-lang')) - api "org.apache.groovy:groovy:4.0.30" - api "org.apache.groovy:groovy-nio:4.0.30" - api "org.apache.groovy:groovy-xml:4.0.30" - api "org.apache.groovy:groovy-json:4.0.30" - api "org.apache.groovy:groovy-templates:4.0.30" - api "org.apache.groovy:groovy-yaml:4.0.30" + api "org.apache.groovy:groovy:5.0.4" + api "org.apache.groovy:groovy-nio:5.0.4" + api "org.apache.groovy:groovy-xml:5.0.4" + api "org.apache.groovy:groovy-json:5.0.4" + api "org.apache.groovy:groovy-templates:5.0.4" + api "org.apache.groovy:groovy-yaml:5.0.4" api "org.slf4j:jcl-over-slf4j:2.0.17" api "org.slf4j:jul-to-slf4j:2.0.17" api "org.slf4j:log4j-over-slf4j:2.0.17" @@ -58,11 +58,11 @@ dependencies { testImplementation 'org.subethamail:subethasmtp:3.1.7' testImplementation (project(':nf-lineage')) // test configuration - testFixturesApi ("org.apache.groovy:groovy-test:4.0.30") { exclude group: 'org.apache.groovy' } + testFixturesApi ("org.apache.groovy:groovy-test:5.0.4") { exclude group: 'org.apache.groovy' } testFixturesApi ("org.objenesis:objenesis:3.4") testFixturesApi ("net.bytebuddy:byte-buddy:1.14.17") - testFixturesApi ("org.spockframework:spock-core:2.4-groovy-4.0") { exclude group: 'org.apache.groovy' } - testFixturesApi ('org.spockframework:spock-junit4:2.4-groovy-4.0') { exclude group: 'org.apache.groovy' } + testFixturesApi ("org.spockframework:spock-core:2.4-groovy-5.0") { exclude group: 'org.apache.groovy' } + testFixturesApi ('org.spockframework:spock-junit4:2.4-groovy-5.0') { exclude group: 'org.apache.groovy' } testFixturesApi 'com.google.jimfs:jimfs:1.2' // note: declare as separate dependency to avoid a circular dependency lineageImplementation (project(':nf-lineage')) diff --git a/modules/nextflow/src/main/groovy/nextflow/Session.groovy b/modules/nextflow/src/main/groovy/nextflow/Session.groovy index b17eac20b6..d2e823729d 100644 --- a/modules/nextflow/src/main/groovy/nextflow/Session.groovy +++ b/modules/nextflow/src/main/groovy/nextflow/Session.groovy @@ -1220,7 +1220,7 @@ class Session implements ISession { def fetchContainers() { def result = [:] - if( config.process instanceof Map ) { + if( config.process instanceof Map ) { /* * look for `container` definition at process level diff --git a/modules/nextflow/src/main/groovy/nextflow/cli/CmdLog.groovy b/modules/nextflow/src/main/groovy/nextflow/cli/CmdLog.groovy index 66d88980d1..78ae086128 100644 --- a/modules/nextflow/src/main/groovy/nextflow/cli/CmdLog.groovy +++ b/modules/nextflow/src/main/groovy/nextflow/cli/CmdLog.groovy @@ -220,6 +220,7 @@ class CmdLog extends CmdBase implements CacheBase { /** * Wrap a {@link TraceRecord} instance as a {@link Map} or a {@link Binding} object */ + @Slf4j private static class TraceAdaptor extends Binding { static private int MAX_LINES = 100 @@ -299,13 +300,14 @@ class CmdLog extends CmdBase implements CacheBase { def result = new StringBuilder() path.withReader { reader -> String line - while( (line=reader.readLine()) && c++> executorsMap - private Map,? extends Executor> executors = new HashMap<>() + private Map,Executor> executors = new HashMap<>() - @PackageScope Map,? extends Executor> getExecutors() { executors } + @PackageScope Map,Executor> getExecutors() { executors } ExecutorFactory() { init0(Collections.>emptyList()) diff --git a/modules/nextflow/src/main/groovy/nextflow/extension/CombineOp.groovy b/modules/nextflow/src/main/groovy/nextflow/extension/CombineOp.groovy index 8ef6765faf..ad408fbd19 100644 --- a/modules/nextflow/src/main/groovy/nextflow/extension/CombineOp.groovy +++ b/modules/nextflow/src/main/groovy/nextflow/extension/CombineOp.groovy @@ -75,7 +75,7 @@ class CombineOp { } CombineOp setPivot( pivot ) { - this.pivot = (List)(pivot instanceof List ? pivot : [pivot]) + this.pivot = (List)(pivot instanceof List ? pivot : [pivot]) return this } diff --git a/modules/nextflow/src/main/groovy/nextflow/extension/DumpOp.groovy b/modules/nextflow/src/main/groovy/nextflow/extension/DumpOp.groovy index 24116f63c4..67af0e17b7 100644 --- a/modules/nextflow/src/main/groovy/nextflow/extension/DumpOp.groovy +++ b/modules/nextflow/src/main/groovy/nextflow/extension/DumpOp.groovy @@ -51,7 +51,6 @@ class DumpOp { DumpOp(Map opts, Closure renderer) { checkParams('dump', opts, PARAMS_DUMP) - this.source = source this.tag = opts.tag this.pretty = opts.pretty ?: false this.renderer = renderer @@ -75,11 +74,8 @@ class DumpOp { DataflowWriteChannel apply() { - if( !isEnabled() ) { - if( source instanceof DataflowWriteChannel ) - return (DataflowWriteChannel)source + if( !isEnabled() ) throw new IllegalArgumentException("Illegal dump operator source channel") - } final target = CH.createBy(source) final events = new HashMap(2) diff --git a/modules/nextflow/src/main/groovy/nextflow/extension/PublishOp.groovy b/modules/nextflow/src/main/groovy/nextflow/extension/PublishOp.groovy index 38188f09ae..f373208a52 100644 --- a/modules/nextflow/src/main/groovy/nextflow/extension/PublishOp.groovy +++ b/modules/nextflow/src/main/groovy/nextflow/extension/PublishOp.groovy @@ -62,8 +62,8 @@ class PublishOp { this.source = source this.publishOpts = opts this.path = opts.path as String - if( opts.pathResolver instanceof Closure ) - this.pathResolver = opts.pathResolver as Closure + if( opts.pathResolver instanceof Closure cl ) + this.pathResolver = cl if( opts.index ) this.indexOpts = new IndexOpts(opts.index as Map) } @@ -161,7 +161,7 @@ class PublishOp { // if the closure contained publish statements, use // the resulting mapping to create a saveAs closure final mapping = dsl.build() - if( mapping instanceof Map ) + if( mapping instanceof Map ) return { filename -> filename in mapping ? outputDir.resolve(mapping[filename]) : null } // if the resolved publish path is a string, resolve it @@ -182,11 +182,11 @@ class PublishOp { if( source instanceof Path ) { publish0(source, target) } - else if( source instanceof Collection ) { + else if( source instanceof Collection ) { if( !target.endsWith('/') ) throw new ScriptRuntimeException("Invalid publish target '${target}' for workflow output '${name}' -- should be a directory (end with a `/`) when publishing a collection of files") for( final path : source ) - publish0(path, target) + publish0((Path) path, target) } else { throw new ScriptRuntimeException("Invalid publish source for workflow output '${name}' -- expected a file or collection of files, but received: ${source} [${source.class.simpleName}]") @@ -293,7 +293,7 @@ class PublishOp { return value.collect { el -> if( el instanceof Path ) return normalizePath(el, targetResolver) - if( el instanceof Collection ) + if( el instanceof Collection ) return normalizeValue(el, targetResolver) if( el instanceof Map ) return normalizeValue(el, targetResolver) @@ -305,7 +305,7 @@ class PublishOp { return value.collectEntries { k, v -> if( v instanceof Path ) return [k, normalizePath(v, targetResolver)] - if( v instanceof Collection ) + if( v instanceof Collection ) return [k, normalizeValue(v, targetResolver)] if( v instanceof Map ) return [k, normalizeValue(v, targetResolver)] @@ -332,7 +332,7 @@ class PublishOp { // if the target resolver is a closure, use it to transform // the source filename to the target path - if( targetResolver instanceof Closure ) { + if( targetResolver instanceof Closure ) { // note: the closure can return null to e.g. not // publish specific files final relPath = sourceDir.relativize(path).toString() diff --git a/modules/nextflow/src/main/groovy/nextflow/extension/SplitOp.groovy b/modules/nextflow/src/main/groovy/nextflow/extension/SplitOp.groovy index db0e58462e..e9e00e7c07 100644 --- a/modules/nextflow/src/main/groovy/nextflow/extension/SplitOp.groovy +++ b/modules/nextflow/src/main/groovy/nextflow/extension/SplitOp.groovy @@ -94,7 +94,7 @@ class SplitOp { multiSplit = true pairedEnd = true } - if( params.elem instanceof List ) { + if( params.elem instanceof List ) { indexes = params.elem as List multiSplit = true } diff --git a/modules/nextflow/src/main/groovy/nextflow/file/DirListener.groovy b/modules/nextflow/src/main/groovy/nextflow/file/DirListener.groovy index 2bac280727..bfb047e12a 100644 --- a/modules/nextflow/src/main/groovy/nextflow/file/DirListener.groovy +++ b/modules/nextflow/src/main/groovy/nextflow/file/DirListener.groovy @@ -49,7 +49,7 @@ interface DirListener { * @param events the list of events to watch * @return */ - default WatchEvent.Kind[] stringToWatchEvents(String events = null){ + default WatchEvent.Kind[] stringToWatchEvents(String events) { def result = [] if( !events ) result << ENTRY_CREATE diff --git a/modules/nextflow/src/main/groovy/nextflow/processor/PublishDir.groovy b/modules/nextflow/src/main/groovy/nextflow/processor/PublishDir.groovy index 1809f848fe..ab172cb7d8 100644 --- a/modules/nextflow/src/main/groovy/nextflow/processor/PublishDir.groovy +++ b/modules/nextflow/src/main/groovy/nextflow/processor/PublishDir.groovy @@ -151,7 +151,7 @@ class PublishDir { void setPath( def value ) { final resolved = value instanceof Closure ? value.call() : value - if( resolved instanceof String || resolved instanceof GString ) + if( resolved instanceof CharSequence ) nullPathWarn = checkNull(resolved.toString()) this.path = FileHelper.toCanonicalPath(resolved) } @@ -169,7 +169,7 @@ class PublishDir { ? tags.call() : tags - if( result instanceof Map ) + if( result instanceof Map ) return result throw new IllegalArgumentException("Invalid publishDir tags attribute: $tags") diff --git a/modules/nextflow/src/main/groovy/nextflow/processor/TaskConfig.groovy b/modules/nextflow/src/main/groovy/nextflow/processor/TaskConfig.groovy index e60998e248..04855c054e 100644 --- a/modules/nextflow/src/main/groovy/nextflow/processor/TaskConfig.groovy +++ b/modules/nextflow/src/main/groovy/nextflow/processor/TaskConfig.groovy @@ -80,8 +80,8 @@ class TaskConfig extends LazyMap implements Cloneable { this.cache.clear() // set the binding context for 'ext' map - if( target.ext instanceof LazyMap ) - (target.ext as LazyMap).binding = context + if( getTarget().ext instanceof LazyMap ext ) + ext.binding = context // set the this object in the task context in order to allow task properties to be resolved in process script context.put(TASK_CONTEXT_PROPERTY_NAME, this) @@ -133,7 +133,7 @@ class TaskConfig extends LazyMap implements Cloneable { } final getRawValue(String key) { - return target.get(key) + return getTarget().get(key) } def get( String key ) { @@ -142,11 +142,11 @@ class TaskConfig extends LazyMap implements Cloneable { def result if( key == 'ext' ) { - if( target.containsKey(key) ) - result = target.get(key) + if( getTarget().containsKey(key) ) + result = getTarget().get(key) else { result = new LazyMap() - target.put(key, result) + getTarget().put(key, result) } } else @@ -167,7 +167,7 @@ class TaskConfig extends LazyMap implements Cloneable { super.setDynamic(flag) } } - target.put(key, value) + getTarget().put(key, value) } else if( key == 'ext' && value instanceof Map ) { super.put( key, new LazyMap(value) ) @@ -181,8 +181,8 @@ class TaskConfig extends LazyMap implements Cloneable { if( super.isDynamic() ) return true - if( target.ext instanceof LazyMap ) - return (target.ext as LazyMap).isDynamic() + if( getTarget().ext instanceof LazyMap ext ) + return ext.isDynamic() return false } @@ -551,7 +551,7 @@ class TaskConfig extends LazyMap implements Cloneable { */ protected boolean getWhenGuard(boolean defValue=true) throws FailedGuardException { - final code = target.get(NextflowDSLImpl.PROCESS_WHEN) + final code = getTarget().get(NextflowDSLImpl.PROCESS_WHEN) if( code == null ) return defValue @@ -571,7 +571,7 @@ class TaskConfig extends LazyMap implements Cloneable { protected TaskClosure getStubBlock() { - final code = target.get(NextflowDSLImpl.PROCESS_STUB) + final code = getTarget().get(NextflowDSLImpl.PROCESS_STUB) if( !code ) return null if( code instanceof TaskClosure ) diff --git a/modules/nextflow/src/main/groovy/nextflow/processor/TaskProcessor.groovy b/modules/nextflow/src/main/groovy/nextflow/processor/TaskProcessor.groovy index 4ebfa77807..fff7e00e18 100644 --- a/modules/nextflow/src/main/groovy/nextflow/processor/TaskProcessor.groovy +++ b/modules/nextflow/src/main/groovy/nextflow/processor/TaskProcessor.groovy @@ -1262,7 +1262,7 @@ class TaskProcessor { if( value instanceof Path ) { files.add((Path)value) } - else if( value instanceof Collection ) { + else if( value instanceof Collection ) { files.addAll(value) } else if( value != null ) { diff --git a/modules/nextflow/src/main/groovy/nextflow/scm/AssetManager.groovy b/modules/nextflow/src/main/groovy/nextflow/scm/AssetManager.groovy index eea1c12f91..9002319c90 100644 --- a/modules/nextflow/src/main/groovy/nextflow/scm/AssetManager.groovy +++ b/modules/nextflow/src/main/groovy/nextflow/scm/AssetManager.groovy @@ -991,8 +991,8 @@ class AssetManager implements Closeable { return List filter = [] - if( modules instanceof List ) { - filter.addAll(modules) + if( modules instanceof List ) { + filter.addAll(modules as List) } else if( modules instanceof String ) { filter.addAll( modules.tokenize(', ') ) diff --git a/modules/nextflow/src/main/groovy/nextflow/script/IterableDef.groovy b/modules/nextflow/src/main/groovy/nextflow/script/IterableDef.groovy index 6a578b8806..fe47a7efe1 100644 --- a/modules/nextflow/src/main/groovy/nextflow/script/IterableDef.groovy +++ b/modules/nextflow/src/main/groovy/nextflow/script/IterableDef.groovy @@ -182,7 +182,11 @@ trait IterableDef { } private DataflowWriteChannel accumulator(DataflowReadChannel source, int i) { - final mapper = { value -> accumulators[i].add(value); return accumulators[i].clone() } + final mapper = { value -> + final next = new ArrayList<>(accumulators[i]) + next.add(value) + return next + } return new MapOp(source, mapper).apply() } diff --git a/modules/nextflow/src/main/groovy/nextflow/script/ProcessDef.groovy b/modules/nextflow/src/main/groovy/nextflow/script/ProcessDef.groovy index 99f3941490..7bc1dfa54b 100644 --- a/modules/nextflow/src/main/groovy/nextflow/script/ProcessDef.groovy +++ b/modules/nextflow/src/main/groovy/nextflow/script/ProcessDef.groovy @@ -108,7 +108,7 @@ class ProcessDef extends BindableDef implements IterableDef, ChainableDef { def result = clone() result.@processName = name result.@simpleName = stripScope(name) - result.@processConfig.processName = name + result.@processConfig.setProcessName(name) return result } diff --git a/modules/nextflow/src/main/groovy/nextflow/script/ScriptBinding.groovy b/modules/nextflow/src/main/groovy/nextflow/script/ScriptBinding.groovy index 0ea8b267c9..03cf8adb45 100644 --- a/modules/nextflow/src/main/groovy/nextflow/script/ScriptBinding.groovy +++ b/modules/nextflow/src/main/groovy/nextflow/script/ScriptBinding.groovy @@ -70,7 +70,8 @@ class ScriptBinding extends WorkflowBinding { // create and populate args args = new ArrayList<>() if( vars.args ) { - if( !(vars.args instanceof List) ) throw new IllegalArgumentException("ScriptBinding 'args' must be a List value") + if( vars.args !instanceof List ) + throw new IllegalArgumentException("ScriptBinding 'args' must be a List value") args.addAll((List)vars.args) } vars.put('args', args) @@ -78,7 +79,8 @@ class ScriptBinding extends WorkflowBinding { // create and populate params params = new ParamsMap() if( vars.params ) { - if( !(vars.params instanceof Map) ) throw new IllegalArgumentException("ScriptBinding 'params' must be a Map value") + if( vars.params !instanceof Map ) + throw new IllegalArgumentException("ScriptBinding 'params' must be a Map value") params.putAll((Map)vars.params) } vars.params = params @@ -210,6 +212,7 @@ class ScriptBinding extends WorkflowBinding { /** * Implements immutable params map */ + @Slf4j @CompileStatic static class ParamsMap implements Map { @@ -244,7 +247,7 @@ class ScriptBinding extends WorkflowBinding { final msg = "Access to undefined parameter `$key` -- Initialise it to a default value eg. `params.$key = some_value`" if( NF.isStrictMode() ) throw new AbortOperationException(msg) - log.warn1(msg, firstOnly: true) + log.warn1(msg) return null } return target.get(key) diff --git a/modules/nextflow/src/main/groovy/nextflow/script/dsl/ProcessConfigBuilder.groovy b/modules/nextflow/src/main/groovy/nextflow/script/dsl/ProcessConfigBuilder.groovy index 9d8e4cbfe6..570f6fc069 100644 --- a/modules/nextflow/src/main/groovy/nextflow/script/dsl/ProcessConfigBuilder.groovy +++ b/modules/nextflow/src/main/groovy/nextflow/script/dsl/ProcessConfigBuilder.groovy @@ -196,10 +196,10 @@ class ProcessConfigBuilder extends ProcessBuilder { continue if( entry.key == 'ext' ) { - if( config.getProperty('ext') instanceof Map ) { + final ext = config.getProperty('ext') + if( ext instanceof Map ) { // update missing 'ext' properties found in 'process' scope - final ext = config.getProperty('ext') as Map - entry.value.each { String k, v -> ext[k] = v } + ext.putAll(entry.value as Map) } continue } diff --git a/modules/nextflow/src/main/groovy/nextflow/script/params/v2/ProcessInputsDef.groovy b/modules/nextflow/src/main/groovy/nextflow/script/params/v2/ProcessInputsDef.groovy index bd9d53a056..10f2230c41 100644 --- a/modules/nextflow/src/main/groovy/nextflow/script/params/v2/ProcessInputsDef.groovy +++ b/modules/nextflow/src/main/groovy/nextflow/script/params/v2/ProcessInputsDef.groovy @@ -36,7 +36,7 @@ class ProcessInputsDef implements Cloneable { * task against the task context and added to the task * environment. */ - private Map env = [:] + private Map env = [:] /** * Input files which will be evaluated for each task @@ -80,7 +80,7 @@ class ProcessInputsDef implements Cloneable { return params.get(i) } - Map getEnv() { + Map getEnv() { return env } diff --git a/modules/nextflow/src/main/groovy/nextflow/trace/ResourcesAggregator.groovy b/modules/nextflow/src/main/groovy/nextflow/trace/ResourcesAggregator.groovy index 2e2d12c906..150c50da6e 100644 --- a/modules/nextflow/src/main/groovy/nextflow/trace/ResourcesAggregator.groovy +++ b/modules/nextflow/src/main/groovy/nextflow/trace/ResourcesAggregator.groovy @@ -55,7 +55,7 @@ class ResourcesAggregator { final summary = summaries[process] summary.names.each { String series -> // the task execution turn a triple - tasks << { return [ process, series, summary.compute(series)] } as Callable + tasks.add({ -> [process, series, summary.compute(series)] } as Callable) } // initialise the result entry result.put(process, new HashMap(10)) diff --git a/modules/nextflow/src/main/groovy/nextflow/util/SerializationHelper.groovy b/modules/nextflow/src/main/groovy/nextflow/util/SerializationHelper.groovy index 05bae4acfc..23c73ed9fa 100644 --- a/modules/nextflow/src/main/groovy/nextflow/util/SerializationHelper.groovy +++ b/modules/nextflow/src/main/groovy/nextflow/util/SerializationHelper.groovy @@ -97,7 +97,7 @@ class KryoHelper { if( v instanceof Class ) kryo.register(k,(Serializer)v.newInstance()) - else if( v instanceof Closure ) + else if( v instanceof Closure ) kryo.register(k, v.call(kryo)) else diff --git a/modules/nextflow/src/main/groovy/nextflow/util/ServiceName.groovy b/modules/nextflow/src/main/groovy/nextflow/util/ServiceName.groovy index 2281047847..3fac2a92d5 100644 --- a/modules/nextflow/src/main/groovy/nextflow/util/ServiceName.groovy +++ b/modules/nextflow/src/main/groovy/nextflow/util/ServiceName.groovy @@ -50,6 +50,6 @@ import java.lang.annotation.Target * @return {@code true} when the executor should have priority over non-important ones */ @Deprecated - boolean important() default Boolean.FALSE + boolean important() default false } diff --git a/modules/nextflow/src/main/groovy/nextflow/util/SimpleAgent.groovy b/modules/nextflow/src/main/groovy/nextflow/util/SimpleAgent.groovy index 7b2bc12ee3..c8790e4d39 100644 --- a/modules/nextflow/src/main/groovy/nextflow/util/SimpleAgent.groovy +++ b/modules/nextflow/src/main/groovy/nextflow/util/SimpleAgent.groovy @@ -106,6 +106,7 @@ class SimpleAgent { } } + @Slf4j @CompileStatic private static class RetrieveValueClosure extends Closure { diff --git a/modules/nextflow/src/main/groovy/nextflow/util/ThreadPoolHelper.groovy b/modules/nextflow/src/main/groovy/nextflow/util/ThreadPoolHelper.groovy index d06addfa73..4cb078dd8c 100644 --- a/modules/nextflow/src/main/groovy/nextflow/util/ThreadPoolHelper.groovy +++ b/modules/nextflow/src/main/groovy/nextflow/util/ThreadPoolHelper.groovy @@ -61,13 +61,12 @@ class ThreadPoolHelper { } } - static protected int pending(ExecutorService pool) { - if( pool instanceof ThreadPoolExecutor) { - final p1 = ((ThreadPoolExecutor)pool) - return p1.getTaskCount() - p1.getCompletedTaskCount() + static protected long pending(ExecutorService pool) { + if( pool instanceof ThreadPoolExecutor tpe ) { + return tpe.getTaskCount() - tpe.getCompletedTaskCount() } - else if( pool instanceof ThreadContainer ) { - return pool.threadCount() + else if( pool instanceof ThreadContainer tc ) { + return tc.threadCount() } return -1 } diff --git a/modules/nextflow/src/test/groovy/nextflow/ast/OpXformTest.groovy b/modules/nextflow/src/test/groovy/nextflow/ast/OpXformTest.groovy index 8469c54e50..f05ec5b779 100644 --- a/modules/nextflow/src/test/groovy/nextflow/ast/OpXformTest.groovy +++ b/modules/nextflow/src/test/groovy/nextflow/ast/OpXformTest.groovy @@ -76,7 +76,7 @@ class OpXformTest extends Specification { then: result instanceof TokenBranchDef - result.closure instanceof Closure + result.closure instanceof Closure result.branches == ['x','y'] and: result.closure.call(0).value == 'hello' diff --git a/modules/nf-commons/build.gradle b/modules/nf-commons/build.gradle index 6be82a655c..2cfffd13a9 100644 --- a/modules/nf-commons/build.gradle +++ b/modules/nf-commons/build.gradle @@ -27,8 +27,8 @@ sourceSets { dependencies { api(project(':nf-lang')) api "ch.qos.logback:logback-classic:1.5.26" - api "org.apache.groovy:groovy:4.0.30" - api "org.apache.groovy:groovy-nio:4.0.30" + api "org.apache.groovy:groovy:5.0.4" + api "org.apache.groovy:groovy-nio:5.0.4" api "org.apache.commons:commons-lang3:3.18.0" api 'com.google.guava:guava:33.0.0-jre' api 'org.pf4j:pf4j:3.12.0' @@ -44,7 +44,7 @@ dependencies { testImplementation(testFixtures(project(":nextflow"))) testFixturesImplementation(project(":nextflow")) - testImplementation "org.apache.groovy:groovy-json:4.0.30" // needed by wiremock + testImplementation "org.apache.groovy:groovy-json:5.0.4" // needed by wiremock testImplementation ('org.wiremock:wiremock:3.13.1') { exclude module: 'groovy-all' } } diff --git a/modules/nf-commons/src/main/nextflow/plugin/PluginRef.groovy b/modules/nf-commons/src/main/nextflow/plugin/PluginRef.groovy index 5780c38aa5..9bdd8e2a02 100644 --- a/modules/nf-commons/src/main/nextflow/plugin/PluginRef.groovy +++ b/modules/nf-commons/src/main/nextflow/plugin/PluginRef.groovy @@ -19,15 +19,15 @@ package nextflow.plugin import com.google.common.hash.Hasher import groovy.transform.Canonical -import nextflow.util.CacheFunnel -import nextflow.util.CacheHelper +import groovy.transform.CompileStatic /** * Model a plugin Id and version * * @author Paolo Di Tommaso */ @Canonical -class PluginRef implements CacheFunnel, Comparable { +@CompileStatic +class PluginRef implements Comparable { /** * Plugin unique ID @@ -56,14 +56,6 @@ class PluginRef implements CacheFunnel, Comparable { return new PluginRef(id) } - @Override - Hasher funnel(Hasher hasher, CacheHelper.HashMode mode) { - hasher.putUnencodedChars(id) - if( version ) - hasher.putUnencodedChars(version) - return hasher - } - @Override String toString() { version ? "${id}@${version}" : id diff --git a/modules/nf-commons/src/main/nextflow/util/CacheFunnel.groovy b/modules/nf-commons/src/main/nextflow/util/CacheFunnel.groovy deleted file mode 100644 index 2fdcb7ba24..0000000000 --- a/modules/nf-commons/src/main/nextflow/util/CacheFunnel.groovy +++ /dev/null @@ -1,16 +0,0 @@ -package nextflow.util - -import com.google.common.hash.Hasher -import groovy.transform.CompileStatic -/** - * Interface to delegate cache hashing to - * a the implementing object - * - * @author Paolo Di Tommaso - */ -@CompileStatic -interface CacheFunnel { - - Hasher funnel(Hasher hasher, CacheHelper.HashMode mode) - -} diff --git a/modules/nf-commons/src/main/nextflow/util/CacheFunnel.java b/modules/nf-commons/src/main/nextflow/util/CacheFunnel.java new file mode 100644 index 0000000000..5587f56181 --- /dev/null +++ b/modules/nf-commons/src/main/nextflow/util/CacheFunnel.java @@ -0,0 +1,14 @@ +package nextflow.util; + +import com.google.common.hash.Hasher; +/** + * Interface to delegate cache hashing to + * a the implementing object + * + * @author Paolo Di Tommaso + */ +public interface CacheFunnel { + + Hasher funnel(Hasher hasher, CacheHelper.HashMode mode); + +} diff --git a/modules/nf-commons/src/main/nextflow/util/CmdLineOptionMap.groovy b/modules/nf-commons/src/main/nextflow/util/CmdLineOptionMap.groovy index 6006001afc..2ca41c3aa7 100644 --- a/modules/nf-commons/src/main/nextflow/util/CmdLineOptionMap.groovy +++ b/modules/nf-commons/src/main/nextflow/util/CmdLineOptionMap.groovy @@ -14,7 +14,7 @@ import groovy.transform.ToString @CompileStatic @ToString(includes = 'options', includeFields = true) @EqualsAndHashCode(includes = 'options', includeFields = true) -class CmdLineOptionMap implements CacheFunnel { +class CmdLineOptionMap { final private Map> options = new LinkedHashMap>() final private static CmdLineOptionMap EMPTY = new CmdLineOptionMap() @@ -74,9 +74,4 @@ class CmdLineOptionMap implements CacheFunnel { } return "[${serialized.join(', ')}]" } - - @Override - Hasher funnel(Hasher hasher, CacheHelper.HashMode mode) { - return CacheHelper.hasher(hasher, options, mode) - } } diff --git a/modules/nf-commons/src/test/nextflow/plugin/PluginUpdaterTest.groovy b/modules/nf-commons/src/test/nextflow/plugin/PluginUpdaterTest.groovy index 5d96d17240..2e1b612e10 100644 --- a/modules/nf-commons/src/test/nextflow/plugin/PluginUpdaterTest.groovy +++ b/modules/nf-commons/src/test/nextflow/plugin/PluginUpdaterTest.groovy @@ -557,7 +557,7 @@ class PluginUpdaterTest extends Specification { and: // Mock pullPlugin0 to prevent real implementation calls - 2 * updater.pullPlugin0(_, _) >> null + 2 * updater.pullPlugin0(_, _) >> { } cleanup: folder?.deleteDir() diff --git a/modules/nf-httpfs/build.gradle b/modules/nf-httpfs/build.gradle index 397b6feebb..a70bddc3e4 100644 --- a/modules/nf-httpfs/build.gradle +++ b/modules/nf-httpfs/build.gradle @@ -30,12 +30,12 @@ sourceSets { dependencies { api project(':nf-commons') api "ch.qos.logback:logback-classic:1.5.26" - api "org.apache.groovy:groovy:4.0.30" - api "org.apache.groovy:groovy-nio:4.0.30" + api "org.apache.groovy:groovy:5.0.4" + api "org.apache.groovy:groovy-nio:5.0.4" api("com.esotericsoftware.kryo:kryo:2.24.0") { exclude group: 'com.esotericsoftware.minlog', module: 'minlog' } /* testImplementation inherited from top gradle build file */ - testImplementation "org.apache.groovy:groovy-json:4.0.30" // needed by wiremock + testImplementation "org.apache.groovy:groovy-json:5.0.4" // needed by wiremock testImplementation ('org.wiremock:wiremock:3.13.1') { exclude module: 'groovy-all' } testImplementation(testFixtures(project(":nextflow"))) diff --git a/modules/nf-lang/build.gradle b/modules/nf-lang/build.gradle index 702842ab35..f17db1cf00 100644 --- a/modules/nf-lang/build.gradle +++ b/modules/nf-lang/build.gradle @@ -23,7 +23,7 @@ compileJava { dependencies { antlr 'me.sunlan:antlr4:4.13.2.6' - api 'org.apache.groovy:groovy:4.0.30' + api 'org.apache.groovy:groovy:5.0.4' api 'org.pf4j:pf4j:3.12.0' testFixturesApi 'com.google.jimfs:jimfs:1.2' diff --git a/modules/nf-lineage/build.gradle b/modules/nf-lineage/build.gradle index 773741a840..b12051187c 100644 --- a/modules/nf-lineage/build.gradle +++ b/modules/nf-lineage/build.gradle @@ -33,7 +33,7 @@ dependencies { api project(':nextflow') testImplementation(testFixtures(project(":nextflow"))) - testImplementation "org.apache.groovy:groovy:4.0.30" - testImplementation "org.apache.groovy:groovy-nio:4.0.30" + testImplementation "org.apache.groovy:groovy:5.0.4" + testImplementation "org.apache.groovy:groovy-nio:5.0.4" } diff --git a/modules/nf-lineage/src/main/nextflow/lineage/LinExtensionImpl.groovy b/modules/nf-lineage/src/main/nextflow/lineage/LinExtensionImpl.groovy index 90c8bc441a..7c71b2f70f 100644 --- a/modules/nf-lineage/src/main/nextflow/lineage/LinExtensionImpl.groovy +++ b/modules/nf-lineage/src/main/nextflow/lineage/LinExtensionImpl.groovy @@ -49,7 +49,8 @@ class LinExtensionImpl implements LinExtension { } private static Map> buildQueryParams(Map opts) { - final queryParams = [type: [FileOutput.class.simpleName] ] + final Map> queryParams = [:] + queryParams['type'] = [FileOutput.class.simpleName] if( opts.workflowRun ) queryParams['workflowRun'] = [opts.workflowRun as String] if( opts.taskRun ) diff --git a/modules/nf-lineage/src/main/nextflow/lineage/LinObserver.groovy b/modules/nf-lineage/src/main/nextflow/lineage/LinObserver.groovy index 655a0c8f16..38e4d4e5be 100644 --- a/modules/nf-lineage/src/main/nextflow/lineage/LinObserver.groovy +++ b/modules/nf-lineage/src/main/nextflow/lineage/LinObserver.groovy @@ -235,9 +235,9 @@ class LinObserver implements TraceObserverV2 { if (value instanceof Path) { return asUriString(storeTaskOutput(task, (Path) value)) } - if (value instanceof Collection) { + if (value instanceof Collection) { final files = new LinkedList() - for (Path it : value) { + for (final it : value) { files.add( asUriString(storeTaskOutput(task, (Path)it)) ) } return files diff --git a/modules/nf-lineage/src/test/nextflow/lineage/LinUtilsTest.groovy b/modules/nf-lineage/src/test/nextflow/lineage/LinUtilsTest.groovy index 631163752b..a2d79b2256 100644 --- a/modules/nf-lineage/src/test/nextflow/lineage/LinUtilsTest.groovy +++ b/modules/nf-lineage/src/test/nextflow/lineage/LinUtilsTest.groovy @@ -86,13 +86,13 @@ class LinUtilsTest extends Specification{ when: def params = LinUtils.getMetadataObject(lidStore, new URI('lid://testKey#params')) then: - params instanceof List + params instanceof List (params as List).size() == 2 when: def outputs = LinUtils.getMetadataObject(lidStore, new URI('lid://testKey#output')) then: - outputs instanceof List + outputs instanceof List def param = (outputs as List)[0] as Parameter param.name == "output" diff --git a/plugins/nf-amazon/build.gradle b/plugins/nf-amazon/build.gradle index 4847b27746..a7bb54d3e7 100644 --- a/plugins/nf-amazon/build.gradle +++ b/plugins/nf-amazon/build.gradle @@ -82,6 +82,6 @@ dependencies { testImplementation(testFixtures(project(":nextflow"))) testImplementation project(':nextflow') - testImplementation "org.apache.groovy:groovy:4.0.30" - testImplementation "org.apache.groovy:groovy-nio:4.0.30" + testImplementation "org.apache.groovy:groovy:5.0.4" + testImplementation "org.apache.groovy:groovy-nio:5.0.4" } diff --git a/plugins/nf-azure/build.gradle b/plugins/nf-azure/build.gradle index d95d09f1ba..60d05f210b 100644 --- a/plugins/nf-azure/build.gradle +++ b/plugins/nf-azure/build.gradle @@ -71,6 +71,6 @@ dependencies { testImplementation(testFixtures(project(":nextflow"))) testImplementation project(':nextflow') - testImplementation "org.apache.groovy:groovy:4.0.30" - testImplementation "org.apache.groovy:groovy-nio:4.0.30" + testImplementation "org.apache.groovy:groovy:5.0.4" + testImplementation "org.apache.groovy:groovy-nio:5.0.4" } diff --git a/plugins/nf-cloudcache/build.gradle b/plugins/nf-cloudcache/build.gradle index 0604786bdd..12e66279cc 100644 --- a/plugins/nf-cloudcache/build.gradle +++ b/plugins/nf-cloudcache/build.gradle @@ -52,7 +52,7 @@ dependencies { compileOnly 'org.pf4j:pf4j:3.12.0' testImplementation(testFixtures(project(":nextflow"))) - testImplementation "org.apache.groovy:groovy:4.0.30" - testImplementation "org.apache.groovy:groovy-nio:4.0.30" + testImplementation "org.apache.groovy:groovy:5.0.4" + testImplementation "org.apache.groovy:groovy-nio:5.0.4" } diff --git a/plugins/nf-codecommit/build.gradle b/plugins/nf-codecommit/build.gradle index 9ec0acee69..5674b051bc 100644 --- a/plugins/nf-codecommit/build.gradle +++ b/plugins/nf-codecommit/build.gradle @@ -57,6 +57,6 @@ dependencies { testImplementation(testFixtures(project(":nextflow"))) testImplementation project(':nextflow') - testImplementation "org.apache.groovy:groovy:4.0.30" - testImplementation "org.apache.groovy:groovy-nio:4.0.30" + testImplementation "org.apache.groovy:groovy:5.0.4" + testImplementation "org.apache.groovy:groovy-nio:5.0.4" } diff --git a/plugins/nf-console/build.gradle b/plugins/nf-console/build.gradle index be31aaa8dd..f8d191079a 100644 --- a/plugins/nf-console/build.gradle +++ b/plugins/nf-console/build.gradle @@ -51,13 +51,13 @@ dependencies { compileOnly 'org.pf4j:pf4j:3.12.0' api("org.apache.groovy:groovy-console:4.0.21-patch.2") { transitive=false } - api("org.apache.groovy:groovy-swing:4.0.30") { transitive=false } + api("org.apache.groovy:groovy-swing:5.0.4") { transitive=false } // this is required by 'groovy-console' api("com.github.javaparser:javaparser-core:3.25.8") testImplementation(testFixtures(project(":nextflow"))) testImplementation project(':nextflow') - testImplementation "org.apache.groovy:groovy:4.0.30" - testImplementation "org.apache.groovy:groovy-nio:4.0.30" + testImplementation "org.apache.groovy:groovy:5.0.4" + testImplementation "org.apache.groovy:groovy-nio:5.0.4" } diff --git a/plugins/nf-google/build.gradle b/plugins/nf-google/build.gradle index 04a7912b42..7d5e188c92 100644 --- a/plugins/nf-google/build.gradle +++ b/plugins/nf-google/build.gradle @@ -63,8 +63,8 @@ dependencies { runtimeOnly 'io.grpc:grpc-netty-shaded:1.75.0' testImplementation(testFixtures(project(":nextflow"))) - testImplementation "org.apache.groovy:groovy:4.0.30" - testImplementation "org.apache.groovy:groovy-nio:4.0.30" + testImplementation "org.apache.groovy:groovy:5.0.4" + testImplementation "org.apache.groovy:groovy-nio:5.0.4" } test { diff --git a/plugins/nf-google/src/main/nextflow/cloud/google/batch/GoogleBatchMachineTypeSelector.groovy b/plugins/nf-google/src/main/nextflow/cloud/google/batch/GoogleBatchMachineTypeSelector.groovy index d21554ec70..418a395893 100644 --- a/plugins/nf-google/src/main/nextflow/cloud/google/batch/GoogleBatchMachineTypeSelector.groovy +++ b/plugins/nf-google/src/main/nextflow/cloud/google/batch/GoogleBatchMachineTypeSelector.groovy @@ -157,7 +157,7 @@ class GoogleBatchMachineTypeSelector { products.collect { new MachineType( - type: it.type, + type: it.type as String, family: it.type.toString().split('-')[0], spotPrice: averageSpotPrice(it.spotPrice as List), onDemandPrice: it.onDemandPrice as float, diff --git a/plugins/nf-k8s/build.gradle b/plugins/nf-k8s/build.gradle index 7a9fc9c2bd..4fc94147b4 100644 --- a/plugins/nf-k8s/build.gradle +++ b/plugins/nf-k8s/build.gradle @@ -56,8 +56,8 @@ dependencies { api 'org.bouncycastle:bcpkix-jdk18on:1.79' testImplementation(testFixtures(project(":nextflow"))) - testImplementation "org.apache.groovy:groovy:4.0.30" - testImplementation "org.apache.groovy:groovy-nio:4.0.30" + testImplementation "org.apache.groovy:groovy:5.0.4" + testImplementation "org.apache.groovy:groovy-nio:5.0.4" } test { diff --git a/plugins/nf-k8s/src/main/nextflow/k8s/model/PodSpecBuilder.groovy b/plugins/nf-k8s/src/main/nextflow/k8s/model/PodSpecBuilder.groovy index 011ecf748d..1ca2b66ea8 100644 --- a/plugins/nf-k8s/src/main/nextflow/k8s/model/PodSpecBuilder.groovy +++ b/plugins/nf-k8s/src/main/nextflow/k8s/model/PodSpecBuilder.groovy @@ -449,10 +449,10 @@ class PodSpecBuilder { container.securityContext = secContext } - final spec = [ - restartPolicy: restart, - containers: [ container ], - ] + final Map spec = [:] + + spec.restartPolicy = restart + spec.containers = [ container ] if( nodeSelector ) spec.nodeSelector = nodeSelector.toSpec() diff --git a/plugins/nf-tower/build.gradle b/plugins/nf-tower/build.gradle index b936aa4476..4f48c8db10 100644 --- a/plugins/nf-tower/build.gradle +++ b/plugins/nf-tower/build.gradle @@ -55,9 +55,9 @@ dependencies { api "com.fasterxml.jackson.core:jackson-databind:2.12.7.1" testImplementation(testFixtures(project(":nextflow"))) - testImplementation "org.apache.groovy:groovy:4.0.30" - testImplementation "org.apache.groovy:groovy-nio:4.0.30" - testImplementation "org.apache.groovy:groovy-json:4.0.30" + testImplementation "org.apache.groovy:groovy:5.0.4" + testImplementation "org.apache.groovy:groovy-nio:5.0.4" + testImplementation "org.apache.groovy:groovy-json:5.0.4" // wiremock required by TowerFusionEnvTest testImplementation "org.wiremock:wiremock:3.13.1" // Address security vulnerabilities CVE-2022-45688 and CVE-2023-5072 diff --git a/plugins/nf-wave/build.gradle b/plugins/nf-wave/build.gradle index 8a5581f04e..bb195d4237 100644 --- a/plugins/nf-wave/build.gradle +++ b/plugins/nf-wave/build.gradle @@ -61,6 +61,6 @@ dependencies { api 'io.seqera:wave-utils:1.31.1' testImplementation(testFixtures(project(":nextflow"))) - testImplementation "org.apache.groovy:groovy:4.0.30" - testImplementation "org.apache.groovy:groovy-nio:4.0.30" + testImplementation "org.apache.groovy:groovy:5.0.4" + testImplementation "org.apache.groovy:groovy-nio:5.0.4" }