Skip to content

Commit 6e35936

Browse files
committed
Move PluginExecAware to nextflow module
Signed-off-by: Ben Sherman <bentshermann@gmail.com>
1 parent 3b676c2 commit 6e35936

9 files changed

Lines changed: 33 additions & 31 deletions

File tree

modules/nf-cli-v1/src/main/groovy/nextflow/cli/PluginAbstractExec.groovy renamed to modules/nextflow/src/main/groovy/nextflow/plugin/cli/PluginAbstractExec.groovy

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,15 @@
1515
*
1616
*/
1717

18-
package nextflow.cli
19-
20-
import java.nio.file.Paths
18+
package nextflow.plugin.cli
2119

2220
import groovy.transform.CompileStatic
2321
import nextflow.Session
24-
import nextflow.config.ConfigCmdAdapter
22+
import nextflow.SysEnv
2523
import nextflow.exception.AbortOperationException
2624
import org.slf4j.Logger
2725
import org.slf4j.LoggerFactory
26+
2827
import static PluginExecAware.CMD_SEP
2928

3029
/**
@@ -38,23 +37,13 @@ trait PluginAbstractExec implements PluginExecAware {
3837
private static Logger log = LoggerFactory.getLogger(PluginAbstractExec)
3938

4039
private Session session
41-
private Launcher launcher
4240

4341
Session getSession() { session }
4442

45-
Launcher getLauncher() { launcher }
46-
4743
abstract List<String> getCommands()
4844

4945
@Override
50-
final int exec(Launcher launcher1, String pluginId, String cmd, List<String> args) {
51-
this.launcher = launcher1
52-
// create the config
53-
final config = new ConfigCmdAdapter()
54-
.setOptions(launcher1.options)
55-
.setBaseDir(Paths.get('.'))
56-
.build()
57-
46+
final int exec(String pluginId, String cmd, List<String> args) {
5847
if( !cmd || cmd !in getCommands() ) {
5948
def msg = cmd ? "Invalid command '$pluginId:$cmd' - usage: nextflow plugin ${pluginId}${CMD_SEP}<command>" : "Usage: nextflow plugin ${pluginId}${CMD_SEP}<command>"
6049
msg += "\nAvailable commands:"
@@ -64,7 +53,8 @@ trait PluginAbstractExec implements PluginExecAware {
6453
}
6554

6655
// create the session object
67-
this.session = new Session(config)
56+
this.session = new Session(getConfig())
57+
6858
// invoke the command
6959
try {
7060
exec(cmd, args)
@@ -78,7 +68,16 @@ trait PluginAbstractExec implements PluginExecAware {
7868
return 0
7969
}
8070

81-
abstract int exec(String cmd, List<String> args)
71+
private Map getConfig() {
72+
final result = [
73+
workDir: SysEnv.get('NXF_WORK') ?: 'work'
74+
]
75+
final cloudCachePath = SysEnv.get('NXF_CLOUDCACHE_PATH')
76+
if( cloudCachePath )
77+
result.cloudcache = [ enabled: true, path: cloudCachePath ]
78+
return result
79+
}
8280

81+
abstract int exec(String cmd, List<String> args)
8382

8483
}

modules/nf-cli-v1/src/main/groovy/nextflow/cli/PluginExecAware.groovy renamed to modules/nextflow/src/main/groovy/nextflow/plugin/cli/PluginExecAware.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*
1616
*/
1717

18-
package nextflow.cli
18+
package nextflow.plugin.cli
1919

2020
/**
2121
* Define the interface for plugin commands
@@ -26,6 +26,6 @@ interface PluginExecAware {
2626

2727
static final String CMD_SEP = ':'
2828

29-
int exec(Launcher launcher, String pluginId, String cmd, List<String> args)
29+
int exec(String pluginId, String cmd, List<String> args)
3030

3131
}

modules/nf-cli-v1/src/main/groovy/nextflow/cli/CmdPlugin.groovy

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717

1818
package nextflow.cli
1919

20-
import static nextflow.cli.PluginExecAware.CMD_SEP
21-
2220
import java.nio.file.Path
2321

2422
import com.beust.jcommander.DynamicParameter
@@ -27,8 +25,11 @@ import com.beust.jcommander.Parameters
2725
import groovy.transform.CompileStatic
2826
import nextflow.exception.AbortOperationException
2927
import nextflow.plugin.Plugins
28+
import nextflow.plugin.cli.PluginExecAware
3029
import nextflow.plugin.util.PluginRefactor
3130
import org.eclipse.jgit.api.Git
31+
32+
import static nextflow.plugin.cli.PluginExecAware.CMD_SEP
3233
/**
3334
* Plugin manager command
3435
*
@@ -89,7 +90,7 @@ class CmdPlugin extends CmdBase {
8990
mapped << "$it.value".toString()
9091
}
9192
args.addAll(mapped)
92-
final ret = plugin.exec(getLauncher(), target, cmd, args)
93+
final ret = plugin.exec(target, cmd, args)
9394
// use explicit exit to invoke the system shutdown hooks
9495
System.exit(ret)
9596
}

modules/nf-cli-v1/src/main/groovy/nextflow/config/ConfigCmdAdapter.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ class ConfigCmdAdapter {
351351
if( cmdRun.libPath )
352352
config.libDir = cmdRun.libPath
353353

354-
else if ( !config.isSet('libDir') && env.get('NXF_LIB') )
354+
else if ( !config.libDir && env.get('NXF_LIB') )
355355
config.libDir = env.get('NXF_LIB')
356356

357357
// -- override 'process' parameters defined on the cmd line

plugins/nf-tower/src/main/io/seqera/tower/plugin/CacheCommand.groovy

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ package io.seqera.tower.plugin
2020
import groovy.transform.CompileStatic
2121
import groovy.util.logging.Slf4j
2222
import nextflow.SysEnv
23-
import nextflow.cli.PluginAbstractExec
23+
import nextflow.plugin.cli.PluginAbstractExec
2424
/**
2525
* Implements nextflow cache and restore commands
2626
*
@@ -60,10 +60,11 @@ class CacheCommand implements PluginAbstractExec {
6060
}
6161

6262
protected void cacheRestore() {
63-
if( !getSession().cloudCachePath ) {
63+
final env = SysEnv.get()
64+
if( !env.get('NXF_CLOUDCACHE_PATH') ) {
6465
log.debug "Running Nextflow cache restore"
6566
// legacy cache manager
66-
new CacheManager(System.getenv()).restoreCacheFiles()
67+
new CacheManager(env).restoreCacheFiles()
6768
}
6869
else {
6970
// this command is only kept for backward compatibility

plugins/nf-tower/src/main/io/seqera/tower/plugin/TowerPlugin.groovy

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ package io.seqera.tower.plugin
2020
import groovy.transform.CompileStatic
2121
import groovy.util.logging.Slf4j
2222
import nextflow.plugin.BasePlugin
23-
import nextflow.cli.PluginExecAware
23+
import nextflow.plugin.cli.PluginExecAware
2424
import org.pf4j.PluginWrapper
2525
/**
2626
* Seqera Platform plugin
@@ -31,7 +31,8 @@ import org.pf4j.PluginWrapper
3131
@CompileStatic
3232
class TowerPlugin extends BasePlugin implements PluginExecAware {
3333

34-
@Delegate private CacheCommand delegate
34+
@Delegate
35+
private CacheCommand delegate
3536

3637
TowerPlugin(PluginWrapper wrapper) {
3738
super(wrapper)

plugins/nf-wave/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ configurations {
4444
}
4545

4646
dependencies {
47-
compileOnly project(':nf-cli-v1')
47+
compileOnly project(':nextflow')
4848
compileOnly 'org.slf4j:slf4j-api:2.0.17'
4949
compileOnly 'org.pf4j:pf4j:3.12.0'
5050
compileOnly 'io.seqera:lib-trace:0.1.0'

plugins/nf-wave/src/main/io/seqera/wave/plugin/WavePlugin.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
package io.seqera.wave.plugin
1919

2020
import io.seqera.wave.plugin.cli.WaveCmdEntry
21-
import nextflow.cli.PluginExecAware
2221
import nextflow.plugin.BasePlugin
22+
import nextflow.plugin.cli.PluginExecAware
2323
import org.pf4j.PluginWrapper
2424
/**
2525
* Wave plugin entrypoint

plugins/nf-wave/src/main/io/seqera/wave/plugin/cli/WaveCmdEntry.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ import groovy.util.logging.Slf4j
2626
import io.seqera.wave.plugin.ContainerConfig
2727
import io.seqera.wave.plugin.packer.Packer
2828
import io.seqera.wave.plugin.util.BasicCliOpts
29-
import nextflow.cli.PluginAbstractExec
3029
import nextflow.exception.AbortOperationException
3130
import nextflow.io.BucketParser
31+
import nextflow.plugin.cli.PluginAbstractExec
3232
/**
3333
* Implements Wave CLI tool
3434
*

0 commit comments

Comments
 (0)