forked from broadinstitute/gatk-protected
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
281 lines (231 loc) · 9.16 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
//Note: this section 'buildscript` is only for the dependencies of the buildscript itself.
// See the second 'repositories' section below for the actual dependencies of GATK itself
buildscript {
repositories {
mavenCentral()
}
}
plugins {
id "java" // set up default java compile and test tasks
id "application" // provides installDist
id "jacoco" // record code coverage during test execution
id "com.github.johnrengelman.shadow" version "1.2.3" //used to build the shadow and sparkJars
id "com.github.kt3k.coveralls" version "2.6.3" // report coverage data to coveralls
id "com.github.ben-manes.versions" version "0.12.0" //used for identifying dependencies that need updating
}
mainClassName = "org.broadinstitute.hellbender.Main"
//Note: the test suite must use the same defaults. If you change system properties in this list you must also update the one in the test task
//Note: this is copied verbatim from gatk public
applicationDefaultJvmArgs = ["-Dsamjdk.use_async_io_read_samtools=false","-Dsamjdk.use_async_io_write_samtools=true", "-Dsamjdk.use_async_io_write_tribble=false", "-Dsamjdk.compression_level=1"]
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import org.gradle.internal.os.OperatingSystem
def isMacOsX = OperatingSystem.current().macOsX
def customJarPath = hasProperty("custom.jar.dir") ? property("custom.jar.dir") : null;
repositories {
mavenCentral()
maven {
url "https://oss.sonatype.org/content/groups/public"
}
maven {
url "https://repository.cloudera.com/artifactory/cloudera-repos/" // spark-dataflow
}
maven {
url "https://artifactory.broadinstitute.org/artifactory/libs-snapshot/" //for htsjdk snapshots
}
if (customJarPath) {
flatDir {
// Specified by user
dirs customJarPath
}
}
mavenLocal()
}
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.1.201405082137"
}
//NOTE: we ignore contracts for now
compileJava {
options.compilerArgs = ['-proc:none', '-Xlint:all', '-Werror']
}
compileTestJava {
options.compilerArgs = ['-proc:none', '-Xlint:all', '-Werror']
}
build.dependsOn installDist
check.dependsOn installDist
dependencies {
compile files("${System.properties['java.home']}/../lib/tools.jar")
compile 'org.broadinstitute:gatk:4.alpha.1-199-g8377acb-20160713.142718-1'
compile 'org.broadinstitute:hdf5-java-bindings:1.1.0-hdf5_2.11.0'
testCompile 'org.testng:testng:6.8.8'
}
// Dependency change for including MLLib
configurations {
compile.exclude module: 'jul-to-slf4j'
compile.exclude module: 'javax.servlet'
compile.exclude module: 'servlet-api'
compile.exclude group: 'com.esotericsoftware.kryo'
sparkConfiguration {
extendsFrom runtime
// exclude Hadoop and Spark dependencies, since they are provided when running with Spark
// (ref: http://unethicalblogger.com/2015/07/15/gradle-goodness-excluding-depends-from-shadow.html)
exclude group: 'org.apache.hadoop'
exclude module: 'spark-core_2.10'
exclude group: 'org.slf4j'
exclude module: 'jul-to-slf4j'
exclude module: 'javax.servlet'
exclude module: 'servlet-api'
exclude group: 'com.esotericsoftware.kryo'
exclude module: 'spark-mllib_2.10'
exclude group: 'org.scala-lang'
exclude module: 'kryo'
}
}
def findJarByName(Configuration config, String name) {
config.find { File file -> file.name.startsWith(name)}
}
final GATK_LAUNCH = "gatk-launch"
task setupGatkLaunch(type: Copy) {
def gatkJar = findJarByName(configurations.compile, 'gatk')
from {
zipTree( gatkJar ).matching{ include GATK_LAUNCH }.singleFile
}
into "$projectDir"
outputs.file "$projectDir/$GATK_LAUNCH"
description = "extract gatk-launch script from the gatk jar"
}
clean{
delete GATK_LAUNCH //add gatk-launch script to things that need cleaning up since it isn't included automatically
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
def String deriveVersion(){
def stdout = new ByteArrayOutputStream()
try {
logger.info("path is $System.env.PATH")
exec {
commandLine "git", "describe", "--always"
standardOutput = stdout;
ignoreExitValue = true
}
} catch (GradleException e) {
logger.error("Couldn't determine version. " + e.getMessage())
}
return stdout.size() > 0 ? stdout.toString().trim() : "version-unknown"
}
def createSymlinks(archivePath, symlinkLocation) {
exec {
commandLine 'ln', '-fs', archivePath, symlinkLocation
ignoreExitValue = false
}
}
// Suffix is what will be added to the symlink
def createAllSymlinks(destinationDir, archivePath, suffix) {
def finalSuffix = "-" + suffix
if (suffix == "") {
finalSuffix = ""
}
def symlinkLocation = destinationDir.toString() + "/hellbender-protected" + finalSuffix + ".jar"
def symlinkLocation2 = destinationDir.toString() + "/gatk-protected" + finalSuffix + ".jar"
createSymlinks(archivePath.getAbsolutePath(), symlinkLocation)
createSymlinks(archivePath.getAbsolutePath(), symlinkLocation2)
}
version = deriveVersion()
final SNAPSHOT = "-SNAPSHOT"
version = deriveVersion() + SNAPSHOT
boolean isRelease = ! version.endsWith(SNAPSHOT)
logger.info("build for version:" + version);
group = 'org.broadinstitute'
tasks.withType(Jar) {
manifest {
attributes 'Implementation-Title': 'Hellbender-Protected-Tools',
'Implementation-Version': version,
'Main-Class': 'org.broadinstitute.hellbender.Main'
}
}
test {
systemProperty "samjdk.use_async_io_read_samtools", "false"
systemProperty "samjdk.use_async_io_write_samtools", "true"
systemProperty "samjdk.use_async_io_write_tribble", "false"
systemProperty "samjdk.compression_level", "1"
systemProperty "gatk.spark.debug", System.getProperty("gatk.spark.debug")
// enable TestNG support (default is JUnit)
useTestNG{
excludeGroups 'cloud', 'bucket'
}
// set heap size for the test JVM(s)
jvmArgs = ['-Xmx6G']
String CI = "$System.env.CI"
maxParallelForks = CI == "true" ? 1 : 2
if (CI == "true") {
int count = 0
// listen to events in the test execution lifecycle
testLogging {
events "skipped", "failed"
exceptionFormat = "full"
}
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 )
}
}
}
task wrapper(type: Wrapper) {
gradleVersion = '2.13'
}
tasks.withType(ShadowJar) {
from(project.sourceSets.main.output)
baseName = project.name + '-all'
mergeServiceFiles()
// Suggested by the akka devs to make sure that we do not get the spark configuration error.
// http://doc.akka.io/docs/akka/snapshot/general/configuration.html#When_using_JarJar__OneJar__Assembly_or_any_jar-bundler
transform(com.github.jengelman.gradle.plugins.shadow.transformers.AppendingTransformer) {
resource = 'reference.conf'
}
relocate 'com.google.common', 'org.broadinstitute.hellbender.relocated.com.google.common'
zip64 true
exclude 'log4j.properties' // from adam jar as it clashes with hellbender's log4j2.xml
}
shadowJar {
classifier = 'spark_standalone'
doLast {
// Create a symlink to the newly created jar. The name will be hellbender-protected.jar and
// it will be at the same level as the newly created jar. (overwriting symlink, if it exists)
// Please note that this will cause failures in Windows, which does not support symlinks.
createAllSymlinks(destinationDir.toString(), archivePath, "")
}
}
task sparkJar(type: ShadowJar) {
configurations = [project.configurations.sparkConfiguration]
classifier = 'spark'
doLast {
// Create a symlink to the newly created jar. The name will be hellbender-protected.jar and
// it will be at the same level as the newly created jar. (overwriting symlink, if it exists)
// Please note that this will cause failures in Windows, which does not support symlinks.
createAllSymlinks(destinationDir.toString(), archivePath, classifier)
}
}
task installSpark{ dependsOn sparkJar }
task installAll{ dependsOn installSpark, installDist }
tasks.withType(Jar) { dependsOn setupGatkLaunch }