Repository navigation
Expand file tree
/
Copy pathbuild.gradle
More file actions
712 lines (628 loc) · 29.3 KB
/
Copy pathbuild.gradle
File metadata and controls
712 lines (628 loc) · 29.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
/*
* Copyright 2013-2026, Seqera Labs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
plugins {
id 'java'
id 'idea'
}
// Add ability to test with upcoming versions of Groovy
def groovyVer = System.getenv('CI_GROOVY_VERSION')
if (groovyVer) {
def repo = groovyVer.startsWith('com.github.apache:') ? 'https://jitpack.io' : 'https://oss.jfrog.org/oss-snapshot-local/'
logger.lifecycle "Overridden Groovy dependency to use $groovyVer - repository: $repo"
allprojects {
repositories {
maven { url repo }
}
configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
if (details.requested.group == 'org.apache.groovy') {
if( groovyVer.contains(':') )
details.useTarget(groovyVer)
else
details.useVersion(groovyVer)
println ">> Overriding $details.requested with version: $groovyVer"
}
}
}
}
}
def projects(String...args) {
args.collect {project(it)}
}
String gitVersion() {
def p = new ProcessBuilder() .command('sh','-c','git rev-parse --short HEAD') .start()
def r = p.waitFor()
return r==0 ? p.text.trim() : '(unknown)'
}
String gitBranch() {
def fromCI = System.env.GITHUB_REF_NAME
if( fromCI ) return fromCI.trim()
def p = new ProcessBuilder() .command('sh','-c','git rev-parse --abbrev-ref HEAD') .start()
def r = p.waitFor()
def out = r==0 ? p.text.trim() : ''
return (out && out != 'HEAD') ? out : '(unknown)'
}
group = 'io.nextflow'
version = rootProject.file('VERSION').text.trim()
ext.commitId = gitVersion()
allprojects {
apply plugin: 'java'
apply plugin: 'java-test-fixtures'
apply plugin: 'idea'
apply plugin: 'groovy'
apply plugin: 'java-library'
apply plugin: 'jacoco'
java {
// these settings apply to all jvm tooling, including groovy
toolchain {
languageVersion = JavaLanguageVersion.of(25)
}
}
// Target Java 17. For Java sources use --release, which also constrains the
// API surface to the Java 17 stdlib (stronger than -source/-target). Groovy
// does not honor --release, so its bytecode level is pinned via source/target
// on GroovyCompile. Note: --release and -source/-target cannot be combined on
// the same javac task, hence the split across compile task types.
tasks.withType(JavaCompile).configureEach {
options.release = 17
}
tasks.withType(GroovyCompile).configureEach {
sourceCompatibility = '17'
targetCompatibility = '17'
}
idea {
module.inheritOutputDirs = true
}
repositories {
mavenCentral()
maven { url 'https://repo.eclipse.org/content/groups/releases' }
maven { url = "https://s3-eu-west-1.amazonaws.com/maven.seqera.io/releases" }
maven { url = "https://s3-eu-west-1.amazonaws.com/maven.seqera.io/snapshots" }
}
configurations {
// see https://docs.gradle.org/4.1/userguide/dependency_management.html#sub:exclude_transitive_dependencies
all*.exclude group: 'org.apache.groovy', module: 'groovy-all'
all*.exclude group: 'org.apache.groovy', module: 'groovy-cli-picocli'
// groovydoc libs
groovyDoc.extendsFrom runtime
}
dependencies {
// see https://docs.gradle.org/4.1/userguide/dependency_management.html#sec:module_replacement
modules {
module("commons-logging:commons-logging") { replacedBy("org.slf4j:jcl-over-slf4j") }
}
// JUnit Platform launcher required for Gradle 9.1+ when using useJUnitPlatform()
testRuntimeOnly 'org.junit.platform:junit-platform-launcher:1.10.5'
// Documentation required libraries
groovyDoc 'org.fusesource.jansi:jansi:2.4.3'
groovyDoc "org.apache.groovy:groovy-groovydoc:${groovyVersion}"
groovyDoc "org.apache.groovy:groovy-ant:${groovyVersion}"
}
test {
useJUnitPlatform()
minHeapSize = "512m"
maxHeapSize = "4096m"
}
// this is required due to this IDEA bug
// https://youtrack.jetbrains.com/issue/IDEA-129282
sourceSets {
main {
output.resourcesDir = 'build/classes/main'
}
}
// Disable strict javadoc checks
// See http://blog.joda.org/2014/02/turning-off-doclint-in-jdk-8-javadoc.html
if (JavaVersion.current().isJava8Compatible()) {
tasks.withType(Javadoc) {
options.addStringOption('Xdoclint:none', '-quiet')
}
}
tasks.withType(Jar) {
duplicatesStrategy = DuplicatesStrategy.INCLUDE
}
// patched as described here
// http://forums.gradle.org/gradle/topics/gradle_task_groovydoc_failing_with_noclassdeffounderror
tasks.withType(Groovydoc) {
groovyClasspath = project.configurations.groovyDoc
includes = ["nextflow/**"]
}
// Required to run tests on Java 9 and higher in compatibility mode
tasks.withType(Test) {
jvmArgs ([
'--enable-preview',
// preserve Groovy 4 file/path truthiness (a non-null File/Path is truthy regardless of existence) -- see GROOVY-11996
'-Dgroovy.truth.file.exists.enabled=false',
])
// agent mode, auto-detected when tests run under an agent, changes console output
environment 'NXF_AGENT_MODE', 'false'
// skip the EC2 metadata probe, which stalls each AWS client creation off EC2
environment 'AWS_EC2_METADATA_DISABLED', 'true'
// keep the session cache and history out of the developer's ~/.nextflow,
// and start each run from an empty one
final cacheDir = project.layout.buildDirectory.dir('tmp/nxf-cache').get().asFile
environment 'NXF_CACHE_DIR', cacheDir.absolutePath
doFirst {
cacheDir.deleteDir()
cacheDir.mkdirs()
}
}
/**
* Code coverage with JaCoCo.
* See: https://www.jacoco.org/; https://docs.gradle.org/current/userguide/jacoco_plugin.html
*/
// Code coverage report is always generated after tests run
test {
finalizedBy jacocoTestReport
// Only instrument project classes, since third-party classes are never in the report
jacoco {
includes = [
'nextflow.*',
'io.seqera.*',
'groovy.runtime.metaclass.*',
'com.esotericsoftware.minlog.*',
'de.javakaffee.kryoserializers.*'
]
}
}
jacocoTestReport {
// Tests are required to run before generating the code coverage report
dependsOn test
// Remove closure classes from the report, as they are already covered by the enclosing class coverage stats adding only noise.
// See: https://stackoverflow.com/questions/39453696
afterEvaluate {
classDirectories.setFrom(files(classDirectories.files.collect { dir ->
fileTree(dir: dir, excludes: ['**/*$*_closure*'])
}))
}
}
}
// disable jar for root project
jar.enabled = false
/*
* Update the build timestamp in the source source file
*/
task buildInfo {
// Always run this task - never consider it up-to-date
outputs.upToDateWhen { false }
doLast {
def file0 = file('modules/nextflow/src/main/resources/META-INF/build-info.properties')
def buildNum = 0
// Use GitHub Actions run number if available, otherwise increment local counter
if (System.getenv('GITHUB_RUN_NUMBER')) {
buildNum = System.getenv('GITHUB_RUN_NUMBER').toInteger()
println "Using GitHub Actions run number: $buildNum"
}
// -- update build-info file
file0.text = """\
build=${buildNum}
version=${version}
timestamp=${System.currentTimeMillis()}
commitId=${project.property('commitId')}
""".stripIndent()
}}
/*
* Update release information in nextflow wrapper, dockerfile, and plugin metadata.
*
* This task:
* 1. Updates the NXF_VER version string in the nextflow launch script
* 2. Updates the release version in docker/Dockerfile
* 3. Generates plugins-info.txt with current plugin versions from VERSION files
*
* This task always runs to ensure all release artifacts are updated with current versions.
*/
task releaseInfo {
dependsOn buildInfo
// Always run this task - never consider it up-to-date
outputs.upToDateWhen { false }
doLast {
// -- update 'nextflow' wrapper
def file0 = file('nextflow')
def src = file0.text
src = src.replaceAll(/NXF_VER\=\$\{NXF_VER:-'.*'\}/, 'NXF_VER=\\${NXF_VER:-\'' + version + '\'}')
file0.text = src
// -- update dockerfile
file0 = file('docker/Dockerfile')
src = file0.text
src = src.replaceAll(/releases\/v[0-9a-zA-Z_\-\.]+\//, "releases/v$version/" as String)
file0.text = src
// -- create plugins-info file
def plugins = []
new File(rootProject.rootDir, 'plugins')
.eachDir { if(it.name.startsWith('nf-')) plugins << project(":plugins:${it.name}") }
def meta = plugins.collect { "$it.name@$it.version" }
file('modules/nextflow/src/main/resources/META-INF/plugins-info.txt').text = meta.toSorted().join('\n')
}}
/*
* Guard the nf-agent-pi runner image against silent version drift.
*
* That image IS the distribution unit of the `pi` agent runner, and its tag is the plugin
* VERSION -- a tag `build-image.sh push` treats as immutable, publishing only when it does not
* exist yet. So build-context content that lands WITHOUT a version bump can never reach a
* registry under the tag that names it: the release ships a jar hard-pinned to a tag whose
* content this tree no longer describes, permanently. This task fails the release instead.
*
* It hangs off validatePluginVersions so it runs on every path that already validates plugin
* versions -- `upload`, `deploy` and `release` -- and therefore always before the git tag. It is
* deliberately NOT attached to :plugins:nf-agent-pi:releaseImageIfNotExists: drift is exactly the
* case where the tag already exists and that push is skipped, so this check has to be independent
* of it.
*
* What it cannot see: it compares git trees, not the registry, so a tag pushed by hand outside
* the release chain is invisible to it. That is covered by inspecting the reference
* `plugins/nf-agent-pi/build-image.sh ref` prints, before merging -- doing it here would drag
* docker into `upload` and `deploy`.
*/
task validateAgentImageVersion {
// a question about git history has no file inputs that could make it up-to-date
outputs.upToDateWhen { false }
doLast {
final pluginDir = 'plugins/nf-agent-pi'
final ignoreFile = file("$pluginDir/.dockerignore")
// Self-check, so the guard cannot silently degrade into a no-op that reports success on
// every release -- which would be worse than no guard, since the release plan records
// this task passing as proof that it works.
final disconnected = { String why -> new GradleException(
"the nf-agent-pi drift guard derived no usable paths from $pluginDir/.dockerignore " +
"- a rename or an allowlist edit has disconnected it: $why" as String) }
// The `!` allowlist in .dockerignore is already the single statement of what enters the
// image, so derive the guarded paths from it instead of repeating them here. Deriving is
// what keeps the guard honest: agent-rpc/main_test.go is deliberately not admitted to the
// build context, and a hand-written `agent-rpc/**` would fire on a test-only change.
if( !ignoreFile.exists() )
throw disconnected("$ignoreFile does not exist")
// Prefix every entry: .dockerignore paths are relative to the BUILD CONTEXT while a git
// pathspec is relative to the repo root. Unprefixed they match nothing at all.
final derived = ignoreFile.readLines()
.collect { it.trim() }
.findAll { it.startsWith('!') }
.collect { "$pluginDir/${it.substring(1).trim()}" as String }
if( !derived )
throw disconnected('it admits no `!` allowlist entry')
// the Dockerfile and the allowlist itself are build inputs too, and neither is derivable
// from the allowlist
final guarded = derived + ["$pluginDir/Dockerfile" as String, "$pluginDir/.dockerignore" as String]
final absent = guarded.findAll { !file(it).exists() }
if( absent )
throw disconnected("these paths do not exist: ${absent.join(', ')}")
final git = { List<String> args ->
try {
final proc = new ProcessBuilder(['git'] + args)
.directory(rootProject.rootDir)
.redirectError(ProcessBuilder.Redirect.DISCARD)
.start()
final out = proc.inputStream.getText('UTF-8')
return [ ok: proc.waitFor()==0, out: out.trim() ]
}
catch( IOException e ) {
return [ ok: false, out: '' ] // git is not on PATH
}
}
// Not knowing the answer is a warning, never a failure. No git, not a git repo, and a
// shallow clone all land here. The release job checks out with fetch-depth: 0, so in the
// environment that matters the data is there.
//
// A shallow clone is excluded explicitly, and NOT because `git log` comes back empty:
// measured at depths 2, 3 and 5, it does not. The graft boundary is recorded as having no
// parents, so a path-limited log reports the BOUNDARY commit as the one that last set
// VERSION even when the real bump is older than the window - and the diff from there is
// whatever the window happens to contain, i.e. a false failure on a correct tree.
final versionFile = file("$pluginDir/VERSION")
if( !versionFile.exists() ) {
println "! nf-agent-pi drift guard skipped: $pluginDir/VERSION does not exist"
return
}
final shallow = git(['rev-parse', '--is-shallow-repository'])
if( !shallow.ok ) {
println "! nf-agent-pi drift guard skipped: git is not on PATH, or ${rootProject.rootDir} is not a git repository"
return
}
if( shallow.out == 'true' ) {
println "! nf-agent-pi drift guard skipped: this is a shallow clone, so the commit that last set $pluginDir/VERSION cannot be located - fetch the full history to run it"
return
}
final base = git(['log', '-1', '--format=%H', '--', "$pluginDir/VERSION" as String])
if( !base.ok || !base.out ) {
println "! nf-agent-pi drift guard skipped: no commit in this history sets $pluginDir/VERSION"
return
}
// The window is the last VERSION bump, not the last release tag. The invariant is "the
// image tag this tree names is not already published with different content", which
// release tags do not track -- plugins/nf-agent-pi/VERSION does not even exist at the
// current one, so a tag-anchored guard would be vacuous for a whole release cycle. This
// task reads no tag at all, which is also why an unreleased branch cannot upset it.
final version = versionFile.text.trim()
final diff = git(['diff', '--name-only', "${base.out}..HEAD" as String, '--'] + guarded)
if( !diff.ok ) {
println "! nf-agent-pi drift guard skipped: cannot diff ${base.out.take(9)}..HEAD"
return
}
if( diff.out )
throw new GradleException(
"the nf-agent-pi image build context changed since $pluginDir/VERSION was last " +
"bumped (${base.out.take(9)}, version $version) but the version did not - bump it " +
"and add a changelog.txt entry so the release publishes a new image tag; " +
"$version is already published and immutable.\nChanged:\n " +
diff.out.readLines().join('\n ') as String)
println "✅ nf-agent-pi image validation passed: build context unchanged since $version (${base.out.take(9)})"
}
}
/*
* Validate that plugins-info.txt matches plugin VERSION files and that build-info.properties
* contains the correct build number and commit ID when running in GitHub Actions.
*
* This task ensures:
* 1. All plugin versions in plugins-info.txt match their corresponding VERSION files
* 2. The build number in build-info.properties matches GITHUB_RUN_NUMBER (in CI)
* 3. The commit ID in build-info.properties matches GITHUB_SHA (in CI)
* 4. The nf-agent-pi runner image has not drifted from its VERSION (validateAgentImageVersion)
*
* This validation prevents releases with stale or mismatched metadata.
*/
task validatePluginVersions {
dependsOn buildInfo, validateAgentImageVersion
inputs.file('modules/nextflow/src/main/resources/META-INF/plugins-info.txt')
inputs.file('modules/nextflow/src/main/resources/META-INF/build-info.properties')
inputs.files(fileTree('plugins') { include '*/VERSION' })
doLast {
// Get expected versions from plugin projects
def expected = []
new File(rootProject.rootDir, 'plugins')
.eachDir { if(it.name.startsWith('nf-')) expected << project(":plugins:${it.name}") }
def expectedVersions = expected.collect { "$it.name@$it.version" }.toSorted()
// Get actual versions from plugins-info.txt
def actualVersions = file('modules/nextflow/src/main/resources/META-INF/plugins-info.txt').readLines()
// Compare plugin versions
if (expectedVersions != actualVersions) {
def diffs = []
expectedVersions.eachWithIndex { exp, i ->
def act = actualVersions.size() > i ? actualVersions[i] : 'missing'
if (exp != act) diffs << " expected: $exp, actual: $act"
}
throw new GradleException("Plugin version mismatch:\n${diffs.join('\n')}\nRun 'make assemble' to fix.")
}
// A plugin's `nextflowVersion` is a MINIMUM core requirement, written into the jar manifest
// as `Plugin-Requires` and enforced at runtime by BasePlugin.start(). One that names a core
// NEWER than this tree's own VERSION is therefore unloadable from this checkout -- every run
// of that plugin aborts at plugin start with "Failed requirement" -- and, worse, a release
// cut at the current VERSION would ship a plugin the core it ships with refuses to load.
//
// That is easy to write by accident: the requirement has to name the release the plugin
// ships IN, which is the NEXT root VERSION, so a plugin authored ahead of a version bump is
// correct-looking and broken until the bump lands. Checking it here means the bump cannot be
// forgotten silently -- this task runs on `upload`, `deploy` and `release`, i.e. always
// before the git tag.
final coreVersion = rootProject.file('VERSION').text.trim()
// ordered as one number rather than a list: Groovy will not compare two ArrayLists with `>`.
// The multipliers leave room for a 2-digit month and a 4-digit patch, which is well beyond
// anything the calendar scheme in .agents/docs/release.md produces.
final calver = { String v ->
final m = (v =~ /^(\d+)\.(\d+)\.(\d+)/)
return m ? (m[0][1] as int) * 1000000 + (m[0][2] as int) * 10000 + (m[0][3] as int) : null
}
final core = calver(coreVersion)
if( core == null )
throw new GradleException("Cannot parse the root VERSION `${coreVersion}` as a calendar version")
final ahead = []
expected.each { p ->
final gradleFile = new File(p.projectDir, 'build.gradle')
// anchored on the assignment the plugin DSL uses; a plugin that omits it inherits the
// default and is not this check's business
final line = gradleFile.readLines().find { it =~ /^\s*nextflowVersion\s*=/ }
if( !line )
return
final declared = (line =~ /['"]([^'"]+)['"]/).with { it ? it[0][1] : null }
final v = declared ? calver(declared) : null
if( v == null )
throw new GradleException("Cannot parse `nextflowVersion` for ${p.name}: ${line.trim()}")
if( v > core )
ahead << " ${p.name} requires >=${declared}, but the root VERSION is ${coreVersion}"
}
if( ahead )
throw new GradleException(
"Plugin requires a Nextflow version newer than this tree:\n${ahead.join('\n')}\n" +
"Bump the root VERSION to the release these plugins ship in, or lower their `nextflowVersion`.")
// Validate build-info.properties - require GitHub Actions environment variables
if (!System.getenv('GITHUB_RUN_NUMBER')) {
throw new GradleException("GITHUB_RUN_NUMBER environment variable is required")
}
if (!System.getenv('GITHUB_SHA')) {
throw new GradleException("GITHUB_SHA environment variable is required")
}
def buildInfoFile = file('modules/nextflow/src/main/resources/META-INF/build-info.properties')
def props = new Properties()
buildInfoFile.withInputStream { props.load(it) }
def actualBuild = props.getProperty('build')
def expectedBuild = System.getenv('GITHUB_RUN_NUMBER')
if (actualBuild != expectedBuild) {
throw new GradleException("Build number mismatch: build-info.properties has '${actualBuild}' but GITHUB_RUN_NUMBER is '${expectedBuild}'. Run 'make assemble' to fix.")
}
def actualCommit = props.getProperty('commitId')
def expectedCommit = System.getenv('GITHUB_SHA').take(9) // GitHub SHA is full hash, we use short form
if (actualCommit != expectedCommit) {
throw new GradleException("Commit ID mismatch: build-info.properties has '${actualCommit}' but GITHUB_SHA is '${expectedCommit}'. Run 'make assemble' to fix.")
}
println "✅ Build info validation passed: build=${actualBuild}, commitId=${actualCommit}"
println "✅ Plugin version validation passed: all ${expected.size()} plugin versions match"
}
}
/*
* Compile sources and copies all libs to target directory
*/
task compile {
dependsOn allprojects.classes
}
def getRuntimeConfigs() {
def names = subprojects
.findAll { prj -> prj.name in ['nextflow','nf-cli-v1','nf-commons','nf-httpfs','nf-lang','nf-lineage'] }
.collect { it.name }
FileCollection result = null
for( def it : names ) {
def cfg = project(it).configurations.getByName('runtimeClasspath')
if( result==null )
result = cfg
else
result += cfg
// this include the module actual jar file
// note: migrating to gradle 7 does not work any more
//result = result + cfg.getOutgoing().getArtifacts().getFiles()
}
return result?.files ?: []
}
/*
* Save the runtime classpath
* NOTE: This task uses a provider to delay execution, but still triggers configuration
* resolution when the provider is evaluated. While not ideal for Gradle 9.1's strict
* configuration resolution requirements, this approach works in practice for our use case.
*/
task exportClasspath {
dependsOn allprojects.jar
// Use provider to delay configuration resolution until task execution
def configurationFiles = provider {
def libs = []
// Resolve configurations during provider evaluation (not ideal but functional)
['nextflow','nf-cli-v1','nf-commons','nf-httpfs','nf-lang','nf-lineage'].each { moduleName ->
def moduleProject = project(":$moduleName")
def cfg = moduleProject.configurations.getByName('runtimeClasspath')
libs.addAll(cfg.files.collect { it.canonicalPath })
}
// Add module jars
['nextflow','nf-cli-v1','nf-commons','nf-httpfs','nf-lang','nf-lineage'].each {
libs << file("modules/$it/build/libs/${it}-${version}.jar").canonicalPath
}
return libs.unique()
}
inputs.files(configurationFiles)
outputs.file('.launch.classpath')
doLast {
def libs = configurationFiles.get()
file('.launch.classpath').text = libs.join(':')
}
}
ext.nexusUsername = project.findProperty('nexusUsername') ?: System.getenv('AWS_ACCESS_KEY_ID')
ext.nexusPassword = project.findProperty('nexusPassword') ?: System.getenv('AWS_SECRET_ACCESS_KEY')
ext.nexusFullName = project.findProperty('nexusFullName')
ext.nexusEmail = project.findProperty('nexusEmail')
// `signing.keyId` property needs to be defined in the `gradle.properties` file
ext.enableSignArchives = project.findProperty('signing.keyId')
ext.coreProjects = projects( ':nextflow', ':nf-cli-v1', ':nf-commons', ':nf-httpfs', ':nf-lang', ':nf-lineage' )
configure(coreProjects) {
group = 'io.nextflow'
version = rootProject.file('VERSION').text.trim()
}
/*
* Maven central deployment
* http://central.sonatype.org/pages/gradle.html
*/
configure(coreProjects) {
apply plugin: 'maven-publish'
apply plugin: 'signing'
task javadocJar(type: Jar) {
archiveClassifier = 'javadoc'
from configurations.groovyDoc
}
task sourcesJar(type: Jar) {
archiveClassifier = 'sources'
from sourceSets.main.allSource
}
publishing {
publications {
mavenJava(MavenPublication) {
suppressPomMetadataWarningsFor('testFixturesApiElements')
suppressPomMetadataWarningsFor('testFixturesRuntimeElements')
from components.java
versionMapping {
usage('java-api') {
fromResolutionOf('runtimeClasspath')
}
usage('java-runtime') {
fromResolutionResult()
}
}
pom {
name = 'Nextflow'
description = 'A DSL modelled around the UNIX pipe concept, that simplifies writing parallel and scalable pipelines in a portable manner'
url = 'http://www.nextflow.io'
licenses {
license {
name = 'The Apache License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
developers {
developer {
id = nexusUsername
name = nexusFullName
email = nexusEmail
}
}
scm {
connection = 'scm:git:https://github.com/nextflow-io/nextflow'
developerConnection = 'scm:git:git@github.com:nextflow-io/nextflow.git'
url = 'https://github.com/nextflow-io/nextflow'
}
}
artifact sourcesJar
artifact javadocJar
}
}
repositories {
maven {
name = 'Seqera'
// change URLs to point to your repos, e.g. http://my.org/repo
def releasesRepoUrl = "s3://maven.seqera.io/releases/"
def snapshotsRepoUrl = "s3://maven.seqera.io/snapshots/"
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
credentials(AwsCredentials) {
accessKey nexusUsername
secretKey nexusPassword
}
}
}
}
signing {
required { enableSignArchives }
sign publishing.publications.mavenJava
}
}
String bytesToHex(byte[] bytes) {
StringBuffer result = new StringBuffer();
for (byte byt : bytes) result.append(Integer.toString((byt & 0xff) + 0x100, 16).substring(1));
return result.toString();
}
task makeDigest { doLast {
byte[] digest
String str = file('nextflow').text
// create sha1
digest = java.security.MessageDigest.getInstance("SHA1").digest(str.getBytes())
file('nextflow.sha1').text = new BigInteger(1, digest).toString(16) + '\n'
// create sha-256
digest = java.security.MessageDigest.getInstance("SHA-256").digest(str.getBytes())
file('nextflow.sha256').text = bytesToHex(digest) + '\n'
// create md5
digest = java.security.MessageDigest.getInstance("MD5").digest(str.getBytes())
file('nextflow.md5').text = bytesToHex(digest) + '\n'
}}
// Make releaseInfo task automatically run makeDigest after updating versions
releaseInfo.finalizedBy makeDigest
task upload {
dependsOn compile
dependsOn coreProjects.publish
dependsOn validatePluginVersions
}
if( System.env.BUILD_PACK ) {
apply from: 'packing.gradle'
}
apply from: 'gradle/bundle.gradle'