Permalink
Newer
100644
358 lines (306 sloc)
13.7 KB
|
|
||
| 1 | import org.gradle.internal.os.OperatingSystem | |
| 2 | ||
|
|
||
| 3 | import javax.tools.ToolProvider | |
| 4 | ||
| 5 | buildscript { | |
| 6 | repositories { | |
| 7 | mavenCentral() | |
| 8 | } | |
| 9 | } | |
| 10 | ||
| 11 | plugins { | |
| 12 | id "java" | |
| 13 | id 'maven' | |
| 14 | id 'signing' | |
| 15 | id 'jacoco' | |
| 16 | id 'application' | |
| 17 | id 'com.palantir.git-version' version '0.5.1' | |
| 18 | id 'com.github.johnrengelman.shadow' version '1.2.3' | |
| 19 | id "com.github.kt3k.coveralls" version '2.6.3' | |
| 20 | id 'org.ajoberstar.grgit' version '1.4.2' | |
| 21 | id 'org.ajoberstar.github-pages' version '1.4.2' | |
| 22 | } | |
| 23 | ||
| 24 | mainClassName = "picard.cmdline.PicardCommandLine" | |
| 25 | ||
| 26 | repositories { | |
| 27 | mavenLocal() | |
| 28 | mavenCentral() | |
|
|
||
| 29 | maven { | |
|
|
||
| 30 | url "https://broadinstitute.jfrog.io/broadinstitute/libs-snapshot/" //for htsjdk snapshots | |
|
|
||
| 31 | } | |
|
|
||
| 32 | } | |
| 33 | ||
| 34 | jacocoTestReport { | |
| 35 | dependsOn test | |
| 36 | group = "Reporting" | |
| 37 | description = "Generate Jacoco coverage reports after running tests." | |
| 38 | additionalSourceDirs = files(sourceSets.main.allJava.srcDirs) | |
| 39 | ||
| 40 | reports { | |
| 41 | xml.enabled = true // coveralls plugin depends on xml format report | |
| 42 | html.enabled = true | |
| 43 | } | |
| 44 | } | |
| 45 | ||
| 46 | jacoco { | |
| 47 | toolVersion = "0.7.5.201505241946" | |
| 48 | } | |
| 49 | ||
|
|
||
| 50 | final htsjdkVersion = System.getProperty('htsjdk.version', '2.10.1') | |
|
|
||
| 51 | ||
|
|
||
| 52 | dependencies { | |
|
|
||
| 53 | compile('com.intel.gkl:gkl:0.5.3') { | |
|
|
||
| 54 | exclude module: 'htsjdk' | |
| 55 | } | |
|
|
||
| 56 | compile 'com.google.guava:guava:15.0' | |
|
|
||
| 57 | compile 'com.github.samtools:htsjdk:' + htsjdkVersion | |
|
|
||
| 58 | //tools dependency for doclet requires sdk devel | |
| 59 | compile(files(((URLClassLoader) ToolProvider.getSystemToolClassLoader()).getURLs())) | |
| 60 | testCompile 'org.testng:testng:6.9.10' | |
|
|
||
| 61 | testCompile 'org.apache.commons:commons-lang3:3.6' | |
|
|
||
| 62 | } | |
| 63 | ||
|
|
||
| 64 | configurations.all { | |
| 65 | resolutionStrategy { | |
| 66 | // force the htsjdk version so we don't get a different one transitively | |
| 67 | force 'com.github.samtools:htsjdk:' + htsjdkVersion | |
| 68 | } | |
|
|
||
| 69 | } | |
| 70 | ||
| 71 | sourceCompatibility = 1.8 | |
| 72 | targetCompatibility = 1.8 | |
| 73 | ||
| 74 | final isRelease = Boolean.getBoolean("release") | |
| 75 | final gitVersion = gitVersion().replaceAll(".dirty", "") | |
| 76 | version = isRelease ? gitVersion : gitVersion + "-SNAPSHOT" | |
| 77 | ||
| 78 | logger.info("build for version:" + version) | |
| 79 | group = 'com.github.broadinstitute' | |
| 80 | ||
| 81 | defaultTasks 'all' | |
| 82 | ||
|
|
||
| 83 | task all(dependsOn: ['jar', 'distZip', 'documentAll', 'shadowJar', 'currentJar']) | |
|
|
||
| 84 | ||
| 85 | jar { | |
| 86 | manifest { | |
| 87 | attributes 'Main-Class': 'picard.cmdline.PicardCommandLine', | |
| 88 | 'Implementation-Title': 'Picard', | |
| 89 | 'Implementation-Vendor': 'Broad Institute', | |
| 90 | 'Implementation-Version': version | |
| 91 | } | |
| 92 | } | |
| 93 | // This is a hack to disable the java 8 default javadoc lint until we fix the html formatting | |
| 94 | if (JavaVersion.current().isJava8Compatible()) { | |
| 95 | tasks.withType(Javadoc) { | |
| 96 | options.addStringOption('Xdoclint:none', '-quiet') | |
| 97 | } | |
| 98 | } | |
| 99 | ||
|
|
||
| 100 | task currentJar(type: Copy){ | |
| 101 | from shadowJar | |
| 102 | into new File(buildDir, "libs") | |
| 103 | rename { string -> "picard.jar"} | |
| 104 | } | |
| 105 | ||
| 106 | shadowJar { | |
| 107 | finalizedBy currentJar | |
| 108 | } | |
| 109 | ||
|
|
||
| 110 | tasks.withType(Test) { | |
| 111 | outputs.upToDateWhen { false } // tests will always rerun | |
| 112 | description = "Runs the unit tests" | |
| 113 | ||
| 114 | useTestNG { | |
| 115 | if (OperatingSystem.current().isUnix()) { | |
| 116 | excludeGroups "slow", "broken" | |
| 117 | } else { | |
| 118 | excludeGroups "slow", "broken", "unix" | |
| 119 | } | |
| 120 | } | |
| 121 | ||
| 122 | // set heap size for the test JVM(s) | |
| 123 | minHeapSize = "1G" | |
| 124 | maxHeapSize = "2G" | |
| 125 | if (System.env.CI == "true") { //if running under a CI output less into the logs | |
| 126 | int count = 0 | |
| 127 | ||
| 128 | beforeTest { descriptor -> | |
| 129 | count++ | |
| 130 | if( count % 100 == 0) { | |
| 131 | logger.lifecycle("Finished "+ Integer.toString(count++) + " tests") | |
| 132 | } | |
| 133 | } | |
| 134 | } else { | |
| 135 | // show standard out and standard error of the test JVM(s) on the console | |
| 136 | testLogging.showStandardStreams = true | |
| 137 | beforeTest { descriptor -> | |
| 138 | logger.lifecycle("Running Test: " + descriptor) | |
| 139 | } | |
| 140 | ||
| 141 | // listen to standard out and standard error of the test JVM(s) | |
| 142 | onOutput { descriptor, event -> | |
| 143 | logger.lifecycle("Test: " + descriptor + " produced standard out/err: " + event.message ) | |
| 144 | } | |
| 145 | } | |
| 146 | ||
| 147 | testLogging { | |
| 148 | testLogging { | |
| 149 | events "skipped", "failed" | |
| 150 | exceptionFormat = "full" | |
| 151 | } | |
| 152 | afterSuite { desc, result -> | |
| 153 | if (!desc.parent) { // will match the outermost suite | |
| 154 | println "Results: ${result.resultType} (${result.testCount} tests, ${result.successfulTestCount} successes, ${result.failedTestCount} failures, ${result.skippedTestCount} skipped)" | |
| 155 | } | |
| 156 | } | |
| 157 | } | |
| 158 | } | |
| 159 | ||
| 160 | ext.htmlDir = new File("build/docs/html") | |
| 161 | ext.htmlDirInc = new File(htmlDir, "_includes") | |
| 162 | ext.commandClasses = ["picard.sam.AddCommentsToBam", "picard.sam.AddOrReplaceReadGroups", "picard.util.BaitDesigner", "picard.fastq.BamToBfq", | |
|
|
||
| 163 | "picard.sam.BamIndexStats", "picard.util.BedToIntervalList", "picard.sam.BuildBamIndex", | |
|
|
||
| 164 | "picard.sam.CalculateReadGroupChecksum", "picard.sam.CleanSam", "picard.analysis.CollectAlignmentSummaryMetrics", | |
| 165 | "picard.analysis.CollectBaseDistributionByCycle", "picard.analysis.CollectGcBiasMetrics", "picard.illumina.quality.CollectHiSeqXPfFailMetrics", | |
| 166 | "picard.analysis.directed.CollectHsMetrics", "picard.illumina.CollectIlluminaBasecallingMetrics", "picard.illumina.CollectIlluminaLaneMetrics", | |
| 167 | "picard.analysis.CollectInsertSizeMetrics", "picard.analysis.CollectJumpingLibraryMetrics", "picard.analysis.CollectMultipleMetrics", | |
| 168 | "picard.analysis.CollectOxoGMetrics", "picard.analysis.CollectQualityYieldMetrics", "picard.analysis.CollectRawWgsMetrics", | |
| 169 | "picard.analysis.directed.CollectTargetedPcrMetrics", "picard.analysis.CollectRnaSeqMetrics", "picard.analysis.CollectRrbsMetrics", | |
| 170 | "picard.analysis.artifacts.CollectSequencingArtifactMetrics", "picard.vcf.CollectVariantCallingMetrics", "picard.analysis.CollectWgsMetrics", | |
| 171 | "picard.analysis.CollectWgsMetricsWithNonZeroCoverage", "picard.analysis.CompareMetrics", "picard.sam.CompareSAMs", | |
| 172 | "picard.analysis.artifacts.ConvertSequencingArtifactToOxoG", "picard.sam.CreateSequenceDictionary", "picard.sam.DownsampleSam", | |
| 173 | "picard.illumina.ExtractIlluminaBarcodes", "picard.sam.markduplicates.EstimateLibraryComplexity", "picard.sam.FastqToSam", "picard.util.FifoBuffer", | |
|
|
||
| 174 | "picard.vcf.MendelianViolations.FindMendelianViolations","picard.fingerprint.CrosscheckFingerprints", "picard.fingerprint.ClusterCrosscheckMetrics", "picard.fingerprint.CheckFingerprint", | |
|
|
||
| 175 | "picard.sam.FilterSamReads", "picard.vcf.filter.FilterVcf", "picard.sam.FixMateInformation", "picard.sam.GatherBamFiles", "picard.vcf.GatherVcfs", | |
| 176 | "picard.vcf.GenotypeConcordance", "picard.illumina.IlluminaBasecallsToFastq", "picard.illumina.IlluminaBasecallsToSam", "picard.illumina.CheckIlluminaDirectory", | |
| 177 | "picard.sam.CheckTerminatorBlock", "picard.util.IntervalListTools", "picard.util.LiftOverIntervalList", "picard.vcf.LiftoverVcf", "picard.vcf.MakeSitesOnlyVcf", | |
| 178 | "picard.sam.markduplicates.MarkDuplicates", "picard.sam.markduplicates.MarkDuplicatesWithMateCigar", "picard.analysis.MeanQualityByCycle", | |
| 179 | "picard.sam.MergeBamAlignment", "picard.sam.MergeSamFiles", "picard.vcf.MergeVcfs", "picard.reference.NormalizeFasta", "picard.sam.PositionBasedDownsampleSam", | |
| 180 | "picard.reference.ExtractSequences", "picard.analysis.QualityScoreDistribution", "picard.vcf.RenameSampleInVcf", "picard.sam.ReorderSam", | |
| 181 | "picard.sam.ReplaceSamHeader", "picard.sam.RevertSam", "picard.sam.RevertOriginalBaseQualitiesAndAddMateCigar", "picard.sam.SamFormatConverter", | |
|
|
||
| 182 | "picard.sam.SamToFastq", "picard.util.ScatterIntervalsByNs", "picard.sam.SetNmMdAndUqTags", | |
| 183 | "picard.sam.SortSam", "picard.vcf.SortVcf", "picard.sam.SplitSamByLibrary", "picard.sam.markduplicates.UmiAwareMarkDuplicatesWithMateCigar", | |
|
|
||
| 184 | "picard.vcf.UpdateVcfSequenceDictionary", "picard.vcf.VcfFormatConverter", "picard.illumina.MarkIlluminaAdapters", "picard.vcf.SplitVcfs", | |
| 185 | "picard.sam.ValidateSamFile", "picard.sam.ViewSam", "picard.vcf.VcfToIntervalList"] | |
| 186 | ||
| 187 | //generate documentation | |
| 188 | ||
| 189 | task documentAll(dependsOn: ['documentCommands', 'createMetricsDoc', 'documentStandardOptions']){ | |
| 190 | doFirst{ | |
| 191 | htmlDirInc.mkdirs() | |
| 192 | } | |
| 193 | } | |
| 194 | ||
| 195 | task documentCommands { | |
| 196 | def previousDocTask = null | |
| 197 | def usageFile = new File(htmlDirInc, "command-line-usage.html") | |
| 198 | def sidebarFile = new File(htmlDirInc, "command-line-sidebar.html") | |
| 199 | ||
| 200 | commandClasses.each { mainClass -> | |
| 201 | task "document_${mainClass}"(type: JavaExec) { | |
| 202 | main ='picard.cmdline.CreateHtmlDocForProgram' | |
| 203 | classpath = sourceSets.main.runtimeClasspath | |
| 204 | args mainClass | |
| 205 | def outputFile = new File(htmlDirInc, mainClass.substring(mainClass.lastIndexOf(".") + 1) + ".html") | |
| 206 | doFirst { | |
| 207 | htmlDirInc.mkdirs() | |
| 208 | standardOutput = new FileOutputStream(outputFile) | |
| 209 | } | |
| 210 | outputs.file outputFile | |
| 211 | ||
| 212 | if (previousDocTask != null) delegate.dependsOn previousDocTask | |
| 213 | previousDocTask = delegate | |
| 214 | documentCommands.dependsOn(delegate) | |
| 215 | doLast { | |
| 216 | usageFile.append("{% include ${mainClass.substring(mainClass.lastIndexOf(".") + 1) + ".html"} %}") | |
| 217 | usageFile.append(System.getProperty("line.separator")) | |
| 218 | sidebarFile.append("<li><a href=\"command-line-overview.html#${mainClass.substring(mainClass.lastIndexOf(".") + 1)}\">${mainClass.substring(mainClass.lastIndexOf(".") + 1)}</a>") | |
| 219 | sidebarFile.append(System.getProperty("line.separator")) | |
| 220 | } | |
| 221 | } | |
| 222 | } | |
| 223 | outputs.dir htmlDirInc | |
| 224 | } | |
| 225 | ||
| 226 | task documentStandardOptions(type: JavaExec) { | |
| 227 | main = 'picard.cmdline.CreateHtmlDocForStandardOptions' | |
| 228 | classpath = sourceSets.main.runtimeClasspath | |
| 229 | def standardOptionsFile = new File(htmlDirInc, "standard-options.html") | |
| 230 | doFirst{ | |
| 231 | htmlDirInc.mkdirs() | |
| 232 | standardOutput = new FileOutputStream(standardOptionsFile) | |
| 233 | } | |
| 234 | outputs.file standardOptionsFile | |
| 235 | } | |
| 236 | ||
|
|
||
| 237 | task createMetricsDoc(dependsOn: classes, type: Javadoc) { | |
| 238 | doFirst { | |
| 239 | htmlDirInc.mkdirs() | |
| 240 | } | |
|
|
||
| 241 | ||
|
|
||
| 242 | source = sourceSets.main.allJava | |
| 243 | classpath = sourceSets.main.runtimeClasspath | |
|
|
||
| 244 | outputs.dir(htmlDirInc) | |
| 245 | ||
| 246 | options.destinationDirectory = htmlDirInc | |
|
|
||
| 247 | options.doclet = 'picard.util.MetricsDoclet' | |
| 248 | options.docletpath = sourceSets.main.runtimeClasspath.asType(List) | |
| 249 | } | |
| 250 | //end generate documentation | |
| 251 | ||
| 252 | task wrapper(type: Wrapper) { | |
| 253 | description = "Regenerate the gradle wrapper" | |
|
|
||
| 254 | gradleVersion = '3.1' | |
|
|
||
| 255 | } | |
| 256 | ||
| 257 | task javadocJar(type: Jar, dependsOn: documentAll) { | |
| 258 | classifier = 'javadoc' | |
| 259 | from 'build/docs/javadoc' | |
| 260 | } | |
| 261 | ||
| 262 | task sourcesJar(type: Jar) { | |
| 263 | from sourceSets.main.allSource | |
| 264 | classifier = 'sources' | |
| 265 | } | |
| 266 | ||
| 267 | /** | |
| 268 | * This specifies what artifacts will be built and uploaded when performing a maven upload. | |
| 269 | */ | |
| 270 | artifacts { | |
| 271 | archives jar | |
| 272 | archives javadocJar | |
| 273 | archives sourcesJar | |
| 274 | } | |
| 275 | ||
| 276 | /** | |
| 277 | * Sign non-snapshot releases with our secret key. This should never need to be invoked directly. | |
| 278 | */ | |
| 279 | signing { | |
| 280 | required { isRelease && gradle.taskGraph.hasTask("uploadArchives") } | |
| 281 | sign configurations.archives | |
| 282 | } | |
| 283 | ||
| 284 | /** | |
| 285 | * Upload a release to sonatype. You must be an authorized uploader and have your sonatype | |
| 286 | * username and password information in your gradle properties file. See the readme for more info. | |
| 287 | * | |
| 288 | * For releasing to your local maven repo, use gradle install | |
| 289 | */ | |
| 290 | uploadArchives { | |
| 291 | repositories { | |
| 292 | mavenDeployer { | |
| 293 | beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) } | |
| 294 | ||
| 295 | repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") { | |
| 296 | authentication(userName: project.findProperty("sonatypeUsername"), password: project.findProperty("sonatypePassword")) | |
| 297 | } | |
| 298 | ||
|
|
||
| 299 | snapshotRepository(url: "https://broadinstitute.jfrog.io/broadinstitute/libs-snapshot-local/") { | |
|
|
||
| 300 | authentication(userName: System.env.ARTIFACTORY_USERNAME, password: System.env.ARTIFACTORY_PASSWORD) | |
| 301 | } | |
| 302 | ||
| 303 | pom.project { | |
| 304 | name 'Picard' | |
| 305 | packaging 'jar' | |
| 306 | 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.' | |
| 307 | url 'http://broadinstitute.github.io/picard/' | |
| 308 | ||
| 309 | developers { | |
| 310 | developer { | |
| 311 | id 'picard' | |
| 312 | name 'Picard Team' | |
| 313 | url 'http://broadinstitute.github.io/picard' | |
| 314 | } | |
| 315 | } | |
| 316 | ||
| 317 | scm { | |
| 318 | url 'git@github.com:broadinstitute/picard.git' | |
| 319 | connection 'scm:git:git@github.com:broadinstitute/picard.git' | |
| 320 | } | |
| 321 | ||
| 322 | licenses { | |
| 323 | license { | |
| 324 | name 'MIT License' | |
| 325 | url 'http://opensource.org/licenses/MIT' | |
| 326 | distribution 'repo' | |
| 327 | } | |
| 328 | } | |
| 329 | } | |
| 330 | } | |
| 331 | } | |
| 332 | doFirst { | |
| 333 | System.out.println("Uploading version $version") | |
| 334 | } | |
| 335 | } | |
| 336 | ||
| 337 | //update static web docs | |
| 338 | task copyJavadoc(dependsOn: 'javadoc', type: Copy) { | |
| 339 | from 'build/docs/javadoc' | |
| 340 | into "$htmlDir/javadoc" | |
| 341 | } | |
| 342 | ||
| 343 | task updateGhPages(dependsOn: ['copyJavadoc', 'documentAll']){ | |
| 344 | outputs.dir htmlDir | |
| 345 | } | |
| 346 | ||
| 347 | updateGhPages.finalizedBy publishGhPages | |
| 348 | ||
| 349 | githubPages { | |
| 350 | repoUri = 'git@github.com:broadinstitute/picard.git' | |
| 351 | targetBranch = 'gh-pages' | |
| 352 | deleteExistingFiles = false | |
| 353 | pages { | |
| 354 | from htmlDir | |
| 355 | into '.' | |
| 356 | } | |
| 357 | } |