File: build.gradle

package info (click to toggle)
picard-tools 2.18.25+dfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 101,284 kB
  • sloc: java: 69,309; xml: 266; sh: 220; makefile: 38
file content (446 lines) | stat: -rw-r--r-- 14,878 bytes parent folder | download
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
import org.gradle.internal.os.OperatingSystem

import javax.tools.ToolProvider

buildscript {
    repositories {
        mavenCentral()
    }
}

plugins {
    id "java"
    id 'maven'
    id 'signing'
    id 'application'
}

mainClassName = "picard.cmdline.PicardCommandLine"

repositories {
    mavenLocal()
    mavenCentral()
    maven {
        url "https://broadinstitute.jfrog.io/broadinstitute/libs-snapshot/" //for htsjdk snapshots
    }
}

/*
jacocoTestReport {
    dependsOn test
    group = "Reporting"
    description = "Generate Jacoco coverage reports after running tests."
    additionalSourceDirs = files(sourceSets.main.allJava.srcDirs)

    reports {
        xml.enabled = true // coveralls plugin depends on xml format report
        html.enabled = true
    }
}

jacoco {
    toolVersion = "0.7.5.201505241946"
}
*/

final requiredJavaVersion = "8"
final buildPrerequisitesMessage = "See https://github.com/broadinstitute/picard/blob/master/README.md#building-picard for information on how to build picard"
// Ensure that we have the right JDK version, a clone of the git repository
def ensureBuildPrerequisites(requiredJavaVersion, buildPrerequisitesMessage) {
    // Make sure we can get a ToolProvider class loader. If not we may have just a JRE, or a JDK from the future.
    //if (ToolProvider.getSystemToolClassLoader() == null) {
    //    throw new GradleException(
    //            "The ClassLoader obtained from the Java ToolProvider is null. "
    //            + "A Java $requiredJavaVersion JDK must be installed. $buildPrerequisitesMessage")
    //}
    //if (!file(".git").isDirectory()) {
    //    throw new GradleException("The Picard Github repository must be cloned using \"git clone\" to run the build. "
    //            + "$buildPrerequisitesMessage")
    //}
}
ensureBuildPrerequisites(requiredJavaVersion, buildPrerequisitesMessage)

final htsjdkVersion = System.getProperty('htsjdk.version', '2.18.2')

// We use a custom shaded build of the NIO library to avoid a regression in the authentication layer.
// GATK does the same, see https://github.com/broadinstitute/gatk/issues/3591
final googleNio = 'org.broadinstitute:google-cloud-nio-GATK4-custom-patch:0.20.4-alpha-GCS-RETRY-FIX:shaded'

// Get the jdk files we need to run javaDoc. We need to use these during compile, testCompile,
// test execution, and gatkDoc generation, but we don't want them as part of the runtime
// classpath and we don't want to redistribute them in the uber jar.
//final javadocJDKFiles = files(((URLClassLoader) ToolProvider.getSystemToolClassLoader()).getURLs())

configurations {
    cloudConfiguration {
        extendsFrom runtime
    }
}

dependencies {
    compile('com.intel.gkl:gkl:0.8.5') {
        exclude module: 'htsjdk'
    }
    compile 'com.google.guava:guava:15.0'
    compile 'org.apache.commons:commons-math3:3.5'
    compile 'com.github.samtools:htsjdk:' + htsjdkVersion
    compile 'org.broadinstitute:barclay:2.0.0'

    // javadoc utilities; compile/test only to prevent redistribution of sdk jars
    //compileOnly(javadocJDKFiles)
    //testCompile(javadocJDKFiles)

    testCompile 'org.testng:testng:debian'
    compile 'org.apache.commons:commons-lang3:debian'
}

configurations.all {
    resolutionStrategy {
        // force the htsjdk version so we don't get a different one transitively
        force 'com.github.samtools:htsjdk:' + htsjdkVersion
    }
}

sourceCompatibility = 1.8
targetCompatibility = 1.8

def getDebianVersion() {
    def dpkgStdOut = new ByteArrayOutputStream()
    exec {
        commandLine "dpkg-parsechangelog", "-S", "Version"
        standardOutput = dpkgStdOut
    }
    return dpkgStdOut.toString().trim().replaceFirst(/(-gradle)?([+]dfsg[.0-9]*)?-[^-]+$/, "")
}

final isRelease = Boolean.getBoolean("release")
final debianVersion = getDebianVersion()
version = debianVersion

logger.info("build for version:" + version)
group = 'com.github.broadinstitute'

defaultTasks 'all'

task all(dependsOn: ['jar', 'distZip', 'javadoc'])

// Source file names for the picard command line properties file. We select and include only one of
// these two files in each jar, renamed to "picardCmdLine.properties", depending on which parser we
// want enabled.
final String legacySourcePropertyFile = 'legacyParserProperties.properties'
final String barclaySourcePropertyFile = 'barclayParserProperties.properties'

// Target name/location for the picard command line properties file; one of the above source
// files will be included at this path/location for runtime access
final String picardTargetPropertiesPath = 'picard'
final String picardTargetPropertyFile = 'picardCmdLine.properties'

sourceSets {
    // no need to include these in the jar files; the correct one is selected by the build to control Barclay
    main {
        resources {
            exclude ('properties.templates/**')
        }
    }
}

tasks.withType(Jar){
    manifest {
        attributes 'Main-Class': 'picard.cmdline.PicardCommandLine',
                'Implementation-Title': 'Picard',
                'Implementation-Vendor': 'Broad Institute',
                'Implementation-Version': version
    }
}

jar {
    from('src/main/resources/properties.templates') {
        // for the default jar, we want the properties file that enables the picard parser
        include legacySourcePropertyFile
        into picardTargetPropertiesPath
        rename { String fileName ->
            fileName.replace(legacySourcePropertyFile, picardTargetPropertyFile)
        }
    }
}

tasks.withType(Javadoc) {
    // do this for all javadoc tasks, including gatkDoc
    options.addStringOption('Xdoclint:none')
    options.addStringOption('XDignore.symbol.file')
}

javadoc {
    options.addStringOption('Xdoclint:none', '-quiet')
}

// Generate Picard Online Doc
task picardDoc(type: Javadoc, dependsOn: ['cleanPicardDoc', classes]) {
    final File picardDocDir = new 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 gatkDoc process instantiates any documented feature classes, so to run it we need the entire
    // runtime classpath, as well as jdk javadoc files such as tools.jar, where com.sun.javadoc lives.
    //classpath = sourceSets.main.runtimeClasspath + javadocJDKFiles
    classpath = 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")
}

/*
task currentJar(type: Copy){
    from shadowJar
    into new File(buildDir, "libs")
    rename { string -> "picard.jar"}
}

shadowJar {
    finalizedBy currentJar
    from('src/main/resources/properties.templates') {
        // for the default jar, we want the properties file that enables the picard parser
        include legacySourcePropertyFile
        into picardTargetPropertiesPath
        rename { String fileName ->
            fileName.replace(legacySourcePropertyFile, picardTargetPropertyFile)
        }
    }
}
*/

/*
task cloudJar(type: com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar)  {
    configurations = [project.configurations.cloudConfiguration]
    from project.sourceSets.main.output
    archiveName 'picardcloud.jar'
}


// Create picardBarclay.jar, which is a identical to picard.jar, but contains a .properties
// file that tells Picard to use the Barclay command line parser instead of the Picard
// command line parser.
//
task barclayShadowJar(type: com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar)  {
    configurations = [project.configurations.runtime]
    from project.sourceSets.main.output
    from('src/main/resources/properties.templates') {
        // for the default jar, we want the properties file that enables the picard parser
        include barclaySourcePropertyFile
        into picardTargetPropertiesPath
        rename { String fileName ->
            fileName.replace(barclaySourcePropertyFile, picardTargetPropertyFile)
        }
    }
    archiveName 'picardBarclay.jar'
}
*/

// Run the tests using the legacy parser only. Assumes that test code is written using
// legacy command line parser syntax.
task legacyTest(type: Test)

// 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.
task barclayTest(type: Test) {
    systemProperty 'picard.convertCommandLine', 'true'
    systemProperty 'picard.useLegacyParser', 'false'
    //systemProperty 'java.library.path', '/usr/lib/gkl:/usr/lib:/usr/lib/x86_64-linux-gnu:/usr/lib/x86_64-linux-gnu/jni'
    environment 'USE_LIBRARY_PATH', 'USE_LIBRARY_PATH'
}

// Run tests using both the legacy and barclay command line parsers.
test {
    dependsOn barclayTest
}

tasks.withType(Test) {
    outputs.upToDateWhen { false } // tests will always rerun
    description = "Runs the unit tests"

    //systemProperty 'java.library.path', '/usr/lib/gkl:/usr/lib:/usr/lib/x86_64-linux-gnu:/usr/lib/x86_64-linux-gnu/jni'
    environment 'USE_LIBRARY_PATH', 'USE_LIBRARY_PATH'

    useTestNG {
        if (OperatingSystem.current().isUnix()) {
            excludeGroups "slow", "broken"
        } else {
            excludeGroups "slow", "broken", "unix"
        }
    }

    maxParallelForks = 1

    // 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)"
            }
        }
    }
}

task wrapper(type: Wrapper) {
    description = "Regenerate the gradle wrapper"
    gradleVersion = '3.1'
}

task javadocJar(type: Jar) {
    classifier = 'javadoc'
    from 'build/docs/javadoc'
}

task sourcesJar(type: Jar) {
    from sourceSets.main.allSource
    classifier = 'sources'
}

/**
 * This specifies what artifacts will be built and uploaded when performing a maven upload.
 */
artifacts {
    archives jar
    archives javadocJar
    archives sourcesJar
}

/**
 * Sign non-snapshot releases with our secret key.  This should never need to be invoked directly.
 */
signing {
    required { isRelease && gradle.taskGraph.hasTask("uploadArchives") }
    sign configurations.archives
}

/**
 * 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
 */
uploadArchives {
    repositories {
        mavenDeployer {
            beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }

            repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
                authentication(userName: project.findProperty("sonatypeUsername"), password: project.findProperty("sonatypePassword"))
            }

            snapshotRepository(url: "https://broadinstitute.jfrog.io/broadinstitute/libs-snapshot-local/") {
                authentication(userName: System.env.ARTIFACTORY_USERNAME, password: System.env.ARTIFACTORY_PASSWORD)
            }

            pom.project {
                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/'

                developers {
                    developer {
                        id 'picard'
                        name 'Picard Team'
                        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'
                    }
                }
            }
        }
    }
    doFirst {
        System.out.println("Uploading version $version")
    }
}

ext.htmlDir = new File("build/docs/html")

//update static web docs
task copyJavadoc(dependsOn: 'javadoc', type: Copy) {
    from 'build/docs/javadoc'
    into "$htmlDir/javadoc"
}

task copyPicardDoc(dependsOn: 'picardDoc', type: Copy){
    from 'build/docs/picarddoc'
    into "$htmlDir/picarddoc"
}

/*
task updateGhPages(dependsOn: ['copyJavadoc', 'copyPicardDoc']){
  outputs.dir htmlDir
}

updateGhPages.finalizedBy publishGhPages

githubPages {
  repoUri = 'git@github.com:broadinstitute/picard.git'
  targetBranch = 'gh-pages'
  deleteExistingFiles = false
  pages {
    from htmlDir
    into 'newdocs'
  }
}
*/