Skip to content

Commit 0bcc8a7

Browse files
committed
Move CLI into nf-cli module
Signed-off-by: Ben Sherman <[email protected]>
1 parent 27ecb89 commit 0bcc8a7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+486
-407
lines changed

build.gradle

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ task compile {
237237

238238
def getRuntimeConfigs() {
239239
def names = subprojects
240-
.findAll { prj -> prj.name in ['nextflow','nf-commons','nf-httpfs','nf-lang'] }
240+
.findAll { prj -> prj.name in ['nextflow','nf-cli-v1','nf-commons','nf-httpfs','nf-lang'] }
241241
.collect { it.name }
242242

243243
FileCollection result = null
@@ -262,8 +262,10 @@ task exportClasspath {
262262
doLast {
263263
def home = System.getProperty('user.home')
264264
def all = getRuntimeConfigs()
265-
def libs = all.collect { File file -> /*println file.canonicalPath.replace(home, '$HOME');*/ file.canonicalPath; }
266-
['nextflow','nf-commons','nf-httpfs','nf-lang'].each {libs << file("modules/$it/build/libs/${it}-${version}.jar").canonicalPath }
265+
def libs = all.collect { File file -> file.canonicalPath }
266+
['nextflow','nf-cli-v1','nf-commons','nf-httpfs','nf-lang'].each {
267+
libs << file("modules/$it/build/libs/${it}-${version}.jar").canonicalPath
268+
}
267269
file('.launch.classpath').text = libs.unique().join(':')
268270
}
269271
}
@@ -276,7 +278,7 @@ ext.nexusEmail = project.findProperty('nexusEmail')
276278
// `signing.keyId` property needs to be defined in the `gradle.properties` file
277279
ext.enableSignArchives = project.findProperty('signing.keyId')
278280

279-
ext.coreProjects = projects( ':nextflow', ':nf-commons', ':nf-httpfs', ':nf-lang' )
281+
ext.coreProjects = projects( ':nextflow', ':nf-cli-v1', ':nf-commons', ':nf-httpfs', ':nf-lang' )
280282

281283
configure(coreProjects) {
282284
group = 'io.nextflow'

modules/nextflow/build.gradle

Lines changed: 21 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,19 @@
1-
plugins {
2-
id "com.gradleup.shadow" version "8.3.5"
3-
}
1+
/*
2+
* Copyright 2013-2025, Seqera Labs
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
416
apply plugin: 'groovy'
5-
apply plugin: 'application'
617

718
sourceSets {
819
main.java.srcDirs = []
@@ -13,10 +24,6 @@ sourceSets {
1324
test.resources.srcDirs = ['src/test/resources']
1425
}
1526

16-
compileGroovy {
17-
options.compilerArgs = ['-XDignore.symbol.file']
18-
}
19-
2027
dependencies {
2128
api(project(':nf-commons'))
2229
api(project(':nf-httpfs'))
@@ -37,14 +44,13 @@ dependencies {
3744
api "commons-lang:commons-lang:2.6"
3845
api "commons-codec:commons-codec:1.15"
3946
api "commons-io:commons-io:2.15.1"
40-
api "com.beust:jcommander:1.35"
4147
api("com.esotericsoftware.kryo:kryo:2.24.0") { exclude group: 'com.esotericsoftware.minlog', module: 'minlog' }
42-
api('org.iq80.leveldb:leveldb:0.12')
43-
api('org.eclipse.jgit:org.eclipse.jgit:7.1.0.202411261347-r')
44-
api ('javax.activation:activation:1.1.1')
45-
api ('javax.mail:mail:1.4.7')
46-
api ('org.yaml:snakeyaml:2.2')
47-
api ('org.jsoup:jsoup:1.15.4')
48+
api 'org.iq80.leveldb:leveldb:0.12'
49+
api 'org.eclipse.jgit:org.eclipse.jgit:7.1.0.202411261347-r'
50+
api 'javax.activation:activation:1.1.1'
51+
api 'javax.mail:mail:1.4.7'
52+
api 'org.yaml:snakeyaml:2.2'
53+
api 'org.jsoup:jsoup:1.15.4'
4854
api 'jline:jline:2.9'
4955
api 'org.pf4j:pf4j:3.12.0'
5056
api 'dev.failsafe:failsafe:3.1.0'
@@ -59,28 +65,4 @@ dependencies {
5965
testFixturesApi ("org.spockframework:spock-core:2.3-groovy-4.0") { exclude group: 'org.apache.groovy' }
6066
testFixturesApi ('org.spockframework:spock-junit4:2.3-groovy-4.0') { exclude group: 'org.apache.groovy' }
6167
testFixturesApi 'com.google.jimfs:jimfs:1.2'
62-
63-
}
64-
65-
66-
test {
67-
minHeapSize = "512m"
68-
maxHeapSize = "4096m"
69-
}
70-
71-
application {
72-
mainClass = 'nextflow.cli.Launcher'
73-
}
74-
75-
run{
76-
args( (project.hasProperty("runCmd") ? project.findProperty("runCmd") : "set a cmd to run").split(' ') )
77-
}
78-
79-
shadowJar {
80-
archiveClassifier='one'
81-
manifest {
82-
attributes 'Main-Class': "$mainClassName"
83-
}
84-
mergeServiceFiles()
85-
mergeGroovyExtensionModules()
8668
}

modules/nextflow/src/main/groovy/nextflow/scm/AssetManager.groovy

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import groovy.transform.PackageScope
2727
import groovy.transform.ToString
2828
import groovy.transform.TupleConstructor
2929
import groovy.util.logging.Slf4j
30-
import nextflow.cli.HubOptions
3130
import nextflow.config.ConfigParserFactory
3231
import nextflow.config.Manifest
3332
import nextflow.exception.AbortOperationException
@@ -98,12 +97,12 @@ class AssetManager {
9897
*
9998
* @param pipeline The pipeline to be managed by this manager e.g. {@code nextflow-io/hello}
10099
*/
101-
AssetManager( String pipelineName, HubOptions cliOpts = null) {
100+
AssetManager( String pipelineName, HubOptions hubOpts = null) {
102101
assert pipelineName
103102
// read the default config file (if available)
104103
def config = ProviderConfig.getDefault()
105104
// build the object
106-
build(pipelineName, config, cliOpts)
105+
build(pipelineName, config, hubOpts)
107106
}
108107

109108
AssetManager( String pipelineName, Map config ) {
@@ -117,19 +116,19 @@ class AssetManager {
117116
*
118117
* @param pipelineName A project name or a project repository Git URL
119118
* @param config A {@link Map} holding the configuration properties defined in the {@link ProviderConfig#DEFAULT_SCM_FILE} file
120-
* @param cliOpts User credentials provided on the command line. See {@link HubOptions} trait
119+
* @param hubOpts User credentials provided on the command line. See {@link HubOptions} trait
121120
* @return The {@link AssetManager} object itself
122121
*/
123122
@PackageScope
124-
AssetManager build( String pipelineName, Map config = null, HubOptions cliOpts = null ) {
123+
AssetManager build( String pipelineName, Map config = null, HubOptions hubOpts = null ) {
125124

126125
this.providerConfigs = ProviderConfig.createFromMap(config)
127126

128127
this.project = resolveName(pipelineName)
129128
this.localPath = checkProjectDir(project)
130-
this.hub = checkHubProvider(cliOpts)
129+
this.hub = checkHubProvider(hubOpts)
131130
this.provider = createHubProvider(hub)
132-
setupCredentials(cliOpts)
131+
setupCredentials(hubOpts)
133132
validateProjectDir()
134133

135134
return this
@@ -152,14 +151,14 @@ class AssetManager {
152151
/**
153152
* Sets the user credentials on the {@link RepositoryProvider} object
154153
*
155-
* @param cliOpts The user credentials specified on the program command line. See {@code HubOptions}
154+
* @param hubOpts The user credentials specified on the program command line. See {@code HubOptions}
156155
*/
157156
@PackageScope
158-
void setupCredentials( HubOptions cliOpts ) {
159-
if( cliOpts?.hubUser ) {
160-
cliOpts.hubProvider = hub
161-
final user = cliOpts.getHubUser()
162-
final pwd = cliOpts.getHubPassword()
157+
void setupCredentials( HubOptions hubOpts ) {
158+
if( hubOpts.user() ) {
159+
hubOpts = new HubOptions(hub, hubOpts.user())
160+
final user = hubOpts.getUser()
161+
final pwd = hubOpts.getPassword()
163162
provider.setCredentials(user, pwd)
164163
}
165164
}
@@ -214,15 +213,15 @@ class AssetManager {
214213
* Find out the "hub provider" (i.e. the platform on which the remote repository is stored
215214
* for example: github, bitbucket, etc) and verifies that it is a known provider.
216215
*
217-
* @param cliOpts The user hub info provider as command line options. See {@link HubOptions}
216+
* @param hubOpts The user hub info provider as command line options. See {@link HubOptions}
218217
* @return The name of hub name e.g. {@code github}, {@code bitbucket}, etc.
219218
*/
220219
@PackageScope
221-
String checkHubProvider( HubOptions cliOpts ) {
220+
String checkHubProvider( HubOptions hubOpts ) {
222221

223222
def result = hub
224223
if( !result )
225-
result = cliOpts?.getHubProvider()
224+
result = hubOpts.provider()
226225
if( !result )
227226
result = guessHubProviderFromGitConfig()
228227
if( !result )
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
* Copyright 2013-2024, Seqera Labs
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package nextflow.scm
18+
19+
import groovy.transform.CompileStatic
20+
/**
21+
* Options for interacting with a git repository provider i.e. GitHub or BitBucket
22+
*
23+
* @author Paolo Di Tommaso <[email protected]>
24+
*/
25+
@CompileStatic
26+
record HubOptions(
27+
String provider,
28+
String user
29+
) {
30+
31+
String getPassword() {
32+
if( !user )
33+
return null
34+
35+
final p = user.indexOf(':')
36+
if( p != -1 )
37+
return user.substring(p + 1)
38+
39+
final console = System.console()
40+
if( !console )
41+
return null
42+
43+
print "Enter your $provider password: "
44+
return new String(console.readPassword())
45+
}
46+
47+
String getUser() {
48+
if( !user )
49+
return user
50+
51+
final p = user.indexOf(':')
52+
return p != -1 ? user.substring(0, p) : user
53+
}
54+
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ import groovy.transform.CompileStatic
2525
import groovy.transform.PackageScope
2626
import groovy.transform.ToString
2727
import groovy.util.logging.Slf4j
28+
import nextflow.Const
2829
import nextflow.NF
2930
import nextflow.NextflowMeta
3031
import nextflow.Session
31-
import nextflow.config.ConfigBuilder
3232
import nextflow.config.Manifest
3333
import nextflow.exception.WorkflowScriptErrorException
3434
import nextflow.trace.WorkflowStats
@@ -265,7 +265,7 @@ class WorkflowMetadata {
265265
this.outputDir = session.outputDir
266266
this.workDir = session.workDir
267267
this.launchDir = Paths.get('.').complete()
268-
this.profile = session.profile ?: ConfigBuilder.DEFAULT_PROFILE
268+
this.profile = session.profile ?: Const.DEFAULT_PROFILE
269269
this.sessionId = session.uniqueId
270270
this.resume = session.resumeMode
271271
this.stubRun = session.stubRun

0 commit comments

Comments
 (0)