forked from broadinstitute/picard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
403 lines (344 loc) · 13.3 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
import org.gradle.internal.os.OperatingSystem
buildscript {
repositories {
mavenCentral()
}
}
plugins {
id "java-library"
id 'maven-publish'
id 'signing'
id 'jacoco'
id 'application'
id 'com.palantir.git-version' version '0.5.1'
id 'com.github.johnrengelman.shadow' version '8.1.1'
id "com.github.kt3k.coveralls" version '2.6.3'
id "org.ajoberstar.grgit" version "5.2.0"
id "org.ajoberstar.git-publish" version "2.1.1"
}
application {
mainClass = "picard.cmdline.PicardCommandLine"
}
repositories {
mavenCentral()
maven {
url "https://broadinstitute.jfrog.io/broadinstitute/libs-snapshot/" //for htsjdk snapshots
}
mavenLocal()
}
final buildPrerequisitesMessage = "See https://github.com/broadinstitute/picard/blob/master/README.md#building-picard for information on how to build picard."
// Check that we're in a folder which git recognizes as a git repository.
// This works for either a standard git clone or one created with `git worktree add`
def looksLikeWereInAGitRepository(){
file(".git").isDirectory() || (file(".git").exists() && file(".git").text.startsWith("gitdir"))
}
// Ensure that we have a clone of the git repository, and resolve any required git-lfs
// resource files that are needed to run the build but are still lfs stub files.
def ensureBuildPrerequisites(buildPrerequisitesMessage) {
if (!JavaVersion.current().equals(JavaVersion.VERSION_17)) {
println("Warning: using Java ${JavaVersion.current()} but only Java 17 has been tested.")
}
if (!JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_17)) {
throw new GradleException(
"A Java 17 compatible (Java 17 or later) version is required to build GATK, but ${JavaVersion.current()} was found. "
+ "$buildPrerequisitesMessage")
}
if (!looksLikeWereInAGitRepository()) {
throw new GradleException("This doesn't appear to be a git folder. " +
"The Picard Github repository must be cloned using \"git clone\" to run the build. " +
"\n$buildPrerequisitesMessage")
}
}
ensureBuildPrerequisites(buildPrerequisitesMessage)
final htsjdkVersion = System.getProperty('htsjdk.version', '4.1.3')
final log4jVersion = System.getProperty('log4j.version', '2.20.0')
dependencies {
api 'com.github.samtools:htsjdk:' + htsjdkVersion
api 'org.broadinstitute:barclay:5.0.0'
//gkl and associated native bindings
implementation('com.intel.gkl:gkl:0.8.11'){
exclude module: 'htsjdk'
}
implementation 'org.broadinstitute:gatk-native-bindings:1.0.0' //this should be redundant when GKL is updated past 0.8.11
//needed for execuing javascript in filter
implementation 'org.openjdk.nashorn:nashorn-core:15.4'
implementation 'com.google.guava:guava:32.1.1-jre'
implementation 'org.apache.commons:commons-math3:3.6.1'
implementation 'org.apache.commons:commons-collections4:4.4'
implementation 'org.apache.commons:commons-lang3:3.12.0'
implementation 'commons-io:commons-io:2.11.0'
//nio plugin providers for google cloud and http(s)
implementation 'com.google.cloud:google-cloud-nio:0.127.0'
implementation 'org.broadinstitute:http-nio:1.1.1'
testImplementation 'org.testng:testng:7.7.0'
constraints {
//log4j api and core, specify these so we don't transitively get old vulnerable versions
implementation 'org.apache.logging.log4j:log4j-api:' +log4jVersion
implementation 'org.apache.logging.log4j:log4j-core:' + log4jVersion
}
}
configurations.configureEach {
resolutionStrategy {
// force the htsjdk version so we don't get a different one transitively
force 'com.github.samtools:htsjdk:' + htsjdkVersion
}
}
java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
withJavadocJar()
withSourcesJar()
}
final isRelease = Boolean.getBoolean("release")
final gitVersion = gitVersion().replaceAll(".dirty", "")
version = isRelease ? gitVersion : gitVersion + "-SNAPSHOT"
logger.info("build for version:" + version)
group = 'com.github.broadinstitute'
defaultTasks 'all'
tasks.register('all') { dependsOn 'jar', 'distZip', 'javadoc', 'shadowJar', 'currentJar', 'picardDoc' }
tasks.withType(Jar).configureEach {
manifest {
attributes 'Main-Class': 'picard.cmdline.PicardCommandLine',
'Implementation-Title': 'Picard',
'Implementation-Vendor': 'Broad Institute',
'htsjdk-Version': htsjdkVersion,
'Implementation-Version': version,
'Multi-Release': 'true'
}
}
tasks.withType(Javadoc).configureEach {
// do this for all javadoc tasks, including gatkDoc
options.addStringOption('Xdoclint:none')
}
javadoc {
options.addStringOption('Xdoclint:none', '-quiet')
}
// Generate Picard Online Doc
tasks.register('picardDoc', Javadoc) {
dependsOn 'cleanPicardDoc', classes
final File picardDocDir = file("build/docs/picarddoc")
doFirst {
// make sure the output folder exists or we can create it
if (!picardDocDir.exists() && !picardDocDir.mkdirs()) {
throw new GradleException(String.format("Failure creating folder (%s) for picardDocDir doc output in task (%s)",
picardDocDir.getAbsolutePath(),
it.name));
}
copy {
from('src/main/resources/picard/helpTemplates')
include 'picardDoc.css'
into picardDocDir
}
}
source = sourceSets.main.allJava
// The picardDoc process instantiates any documented feature classes, so to run it we need the entire
// runtime classpath. The compileClasspath is required in order for the picardDoc doclet process to
// resolve the googleNio classes, which are compile-time only.
classpath = sourceSets.main.compileClasspath + sourceSets.main.runtimeClasspath
options.docletpath = classpath.asType(List)
options.doclet = "picard.util.help.PicardHelpDoclet"
outputs.dir(picardDocDir)
options.destinationDirectory(picardDocDir)
options.addStringOption("settings-dir", "src/main/resources/picard/helpTemplates/");
options.addStringOption("output-file-extension", "html")
options.addStringOption("absolute-version", getVersion())
options.addStringOption("build-timestamp", new Date().format("dd-mm-yyyy hh:mm:ss"))
options.addStringOption("verbose")
// Avoid 'javadoc: error - invalid flag: -notimestamp'. See:
// - https://github.com/gradle/gradle/issues/11898
// - https://github.com/gradle/gradle/issues/11898#issuecomment-993789034
options.noTimestamp(false)
}
tasks.register('currentJar', Copy) {
from shadowJar
into file("$buildDir/libs")
rename { string -> "picard.jar" }
}
shadowJar {
finalizedBy currentJar
}
// Run the tests using the legacy parser only. Assumes that test code is written using
// legacy command line parser syntax.
tasks.register('legacyTest', Test) {
systemProperty 'picard.useLegacyParser', 'true'
}
// Run the tests using the Barclay command line parser (useLegacyParser=false), which requires
// conversion of test command lines from Picard-style command line syntax to Barclay-style syntax.
tasks.register('barclayTest', Test) {
systemProperty 'picard.convertCommandLine', 'true'
}
// Run tests using both the legacy and barclay command line parsers.
test {
dependsOn barclayTest
}
tasks.withType(Test).configureEach {
outputs.upToDateWhen { false } // tests will always rerun
description = "Runs the unit tests"
jvmArgs += [
// required for MergeBamAlignmentTest
'--add-opens', 'java.base/java.io=ALL-UNNAMED'
]
useTestNG {
List excludes = ["slow", "broken"]
if (!OperatingSystem.current().isUnix()) {
excludes << "unix"
}
String TEST_TYPE = "$System.env.TEST_TYPE"
if (TEST_TYPE == "cloud") {
// run only the cloud tests
includeGroups "cloud", "bucket"
excludeGroups(*excludes)
} else if (TEST_TYPE == "all") {
//include everything
excludeGroups(*excludes)
} else {
excludes.addAll("cloud", "bucket")
excludeGroups(*excludes);
}
}
// set heap size for the test JVM(s)
minHeapSize = "1G"
maxHeapSize = "2G"
if (System.env.CI == "true") { //if running under a CI output less into the logs
int count = 0
beforeTest { descriptor ->
count++
if (count % 100 == 0) {
logger.lifecycle("Finished " + Integer.toString(count++) + " tests")
}
}
} else {
// show standard out and standard error of the test JVM(s) on the console
testLogging.showStandardStreams = true
beforeTest { descriptor ->
logger.lifecycle("Running Test: " + descriptor)
}
// listen to standard out and standard error of the test JVM(s)
onOutput { descriptor, event ->
logger.lifecycle("Test: " + descriptor + " produced standard out/err: " + event.message)
}
}
testLogging {
testLogging {
events "skipped", "failed"
exceptionFormat = "full"
}
afterSuite { desc, result ->
if (!desc.parent) { // will match the outermost suite
println "Results: ${result.resultType} (${result.testCount} tests, ${result.successfulTestCount} successes, ${result.failedTestCount} failures, ${result.skippedTestCount} skipped)"
}
}
}
}
jacocoTestReport {
dependsOn legacyTest
group = "Reporting"
description = "Generate Jacoco coverage reports after running tests."
getAdditionalSourceDirs().from(sourceSets.main.allJava.srcDirs)
reports {
xml.required = true // coveralls plugin depends on xml format report
html.required = true
}
}
wrapper {
gradleVersion = '8.5'
}
/**
* Sign non-snapshot releases with our secret key. This should never need to be invoked directly.
*/
signing {
required { isRelease && gradle.taskGraph.hasTask("publish") }
sign publishing.publications
}
/**
* Upload a release to sonatype. You must be an authorized uploader and have your sonatype
* username and password information in your gradle properties file. See the readme for more info.
*
* For releasing to your local maven repo, use gradle install
*/
publishing {
publications {
picard(MavenPublication) {
from components.java
pom {
name = 'Picard'
packaging = 'jar'
description = 'A set of command line tools (in Java) for manipulating high-throughput sequencing (HTS) data and formats such as SAM/BAM/CRAM and VCF.'
url = 'http://broadinstitute.github.io/picard/'
scm {
url = 'git@github.com:broadinstitute/picard.git'
connection = 'scm:git:git@github.com:broadinstitute/picard.git'
}
licenses {
license {
name = 'MIT License'
url = 'http://opensource.org/licenses/MIT'
distribution = 'repo'
}
}
developers {
developer {
id = 'picard'
name = 'Picard Team'
url = 'http://broadinstitute.github.io/picard'
}
}
}
}
}
repositories {
maven {
credentials {
username = isRelease ? project.findProperty("sonatypeUsername") : System.env.ARTIFACTORY_USERNAME
password = isRelease ? project.findProperty("sonatypePassword") : System.env.ARTIFACTORY_PASSWORD
}
def release = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
def snapshot = "https://broadinstitute.jfrog.io/broadinstitute/libs-snapshot-local/"
url = isRelease ? release : snapshot
}
}
}
publish {
doFirst {
System.out.println("Uploading version $version")
}
}
ext.htmlDir = file("build/docs/html")
//update static web docs
tasks.register('copyJavadoc', Copy) {
dependsOn 'javadoc', 'picardDoc'
from 'build/docs/javadoc'
into "$htmlDir/javadoc"
}
tasks.register('copyPicardDoc', Copy) {
dependsOn 'picardDoc'
from 'build/docs/picarddoc'
into "$htmlDir/picarddoc"
}
tasks.register('updateGhPages') {
dependsOn 'copyJavadoc', 'copyPicardDoc'
outputs.dir htmlDir
}
updateGhPages.finalizedBy gitPublishPush
gitPublish {
repoUri = 'git@github.com:broadinstitute/picard.git'
branch = 'gh-pages'
preserve { include '**/*' }
contents {
from('build/docs/html') {
into 'newdocs'
}
}
}
gitPublishCopy {
dependsOn 'updateGhPages', 'copyJavadoc', 'copyPicardDoc'
}
// For Gradle 8 explicitly add 'currentJar' as a dependency of the following tasks.
// For more information, please refer to
// https://docs.gradle.org/8.2.1/userguide/validation_problems.html#implicit_dependency in the Gradle documentation.
['distZip', 'distTar', 'startScripts', 'startShadowScripts', 'generateMetadataFileForPicardPublication'].each {
tasks.named(it).configure {
dependsOn 'currentJar'
}
}