forked from nextflow-io/nextflow
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
418 lines (362 loc) · 13.7 KB
/
build.gradle
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
/*
* Copyright 2013-2024, 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 "io.codearte.nexus-staging" version "0.21.2"
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)'
}
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 {
toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
}
compileJava {
options.release.set(11)
}
tasks.withType(GroovyCompile) {
sourceCompatibility = '11'
targetCompatibility = '11'
}
idea {
module.inheritOutputDirs = true
}
repositories {
mavenCentral()
maven { url 'https://repo.eclipse.org/content/groups/releases' }
maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
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") }
}
// Documentation required libraries
groovyDoc 'org.fusesource.jansi:jansi:2.4.0'
groovyDoc "org.apache.groovy:groovy-groovydoc:4.0.23"
groovyDoc "org.apache.groovy:groovy-ant:4.0.23"
}
test {
useJUnitPlatform()
}
// 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 ([
'-Dorg.spockframework.mock.ignoreByteBuddy=true',
'--enable-preview',
'--add-opens=java.base/java.lang=ALL-UNNAMED',
'--add-opens=java.base/java.io=ALL-UNNAMED',
'--add-opens=java.base/java.nio=ALL-UNNAMED',
'--add-opens=java.base/java.nio.file.spi=ALL-UNNAMED',
'--add-opens=java.base/java.net=ALL-UNNAMED',
'--add-opens=java.base/java.util=ALL-UNNAMED',
'--add-opens=java.base/java.util.concurrent.locks=ALL-UNNAMED',
'--add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED',
'--add-opens=java.base/sun.nio.ch=ALL-UNNAMED',
'--add-opens=java.base/sun.nio.fs=ALL-UNNAMED',
'--add-opens=java.base/sun.net.www.protocol.http=ALL-UNNAMED',
'--add-opens=java.base/sun.net.www.protocol.https=ALL-UNNAMED',
'--add-opens=java.base/sun.net.www.protocol.ftp=ALL-UNNAMED',
'--add-opens=java.base/sun.net.www.protocol.file=ALL-UNNAMED',
'--add-opens=java.base/jdk.internal.misc=ALL-UNNAMED',
'--add-opens=java.base/jdk.internal.vm=ALL-UNNAMED',
])
}
/**
* 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 }
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 { doLast {
def file0 = file('modules/nextflow/src/main/resources/META-INF/build-info.properties')
def buildNum = 0
def src = file0.text
src.find(/build *= *([0-9]*)/) { buildNum = it[1]?.toInteger()+1 }
if( !buildNum ) {
println "WARN: Unable to find current build number"
}
file0.text = src
// -- update build-info file
file0.text = """\
build=${buildNum}
version=${version}
timestamp=${System.currentTimeMillis()}
commitId=${project.property('commitId')}
""".stripIndent()
// -- update 'nextflow' wrapper
file0 = file('nextflow')
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')
}}
/*
* 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-commons','nf-httpfs'] }
.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
}
/*
* Save the runtime classpath
*/
task exportClasspath {
dependsOn allprojects.jar
doLast {
def home = System.getProperty('user.home')
def all = getRuntimeConfigs()
def libs = all.collect { File file -> /*println file.canonicalPath.replace(home, '$HOME');*/ file.canonicalPath; }
['nextflow','nf-commons','nf-httpfs'].each {libs << file("modules/$it/build/libs/${it}-${version}.jar").canonicalPath }
file('.launch.classpath').text = libs.unique().join(':')
}
}
ext.nexusUsername = project.findProperty('nexusUsername')
ext.nexusPassword = project.findProperty('nexusPassword')
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-commons', ':nf-httpfs' )
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:[email protected]:nextflow-io/nextflow.git'
url = 'https://github.com/nextflow-io/nextflow'
}
}
artifact sourcesJar
artifact javadocJar
}
}
repositories {
maven {
// change URLs to point to your repos, e.g. http://my.org/repo
def releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
def snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots/"
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
credentials(PasswordCredentials) {
username nexusUsername
password 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'
}}
task upload {
dependsOn compile
dependsOn makeDigest
dependsOn coreProjects.publish
}
/*
* Configure Nextflow staging plugin -- https://github.com/Codearte/gradle-nexus-staging-plugin
* It adds the tasks
* - closeRepository
* - releaseRepository
* - closeAndReleaseRepository
*/
nexusStaging {
packageGroup = 'io.nextflow'
delayBetweenRetriesInMillis = 10_000
}
if( System.env.BUILD_PACK ) {
apply from: 'packing.gradle'
}