forked from magicDGS/ReadTools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
255 lines (212 loc) · 8.99 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
import javax.tools.ToolProvider
import com.github.jengelman.gradle.plugins.shadow.transformers.ApacheLicenseResourceTransformer
// Dependencies for the buildscript (not the program)
buildscript {
repositories {
mavenCentral()
jcenter() // for shadow plugin
}
}
plugins {
id "java"
id "application"
id "jacoco"
id 'com.github.johnrengelman.shadow' version '2.0.4'
id 'com.palantir.git-version' version '0.11.0' // for the git version
}
apply from: 'gradle/jacoco.coverage.gradle'
// No Windows support
startScripts {
doLast {
delete windowsScript
}
}
// it is a release only if the boolean is a release and the git version does not contain .dirty
final isRelease = !gitVersion().contains(".dirty") && Boolean.getBoolean("release")
group = 'org.magicdgs'
version = (isRelease ? gitVersion() : gitVersion() + "-SNAPSHOT").replaceAll(".dirty", "")
description = """Tools for sequencing barcoded read data (in FASTQ/BAM format)"""
def developer = "Daniel Gomez-Sanchez"
def contact = "daniel.gomez.sanchez@hotmail.es"
sourceCompatibility = 1.8
targetCompatibility = 1.8
mainClassName = group + "." + rootProject.name.toLowerCase() + ".Main"
String documentationPackage = group + "." + rootProject.name.toLowerCase() + ".documentation";
repositories {
mavenCentral()
maven {
url "https://broadinstitute.jfrog.io/broadinstitute/libs-snapshot/"
}
// TODO: remove the GitHub-based repo once we are not using a patched GATK version (https://github.com/magicDGS/ReadTools/issues/443)
maven { url 'https://jitpack.io' }
}
// versions for the dependencies to resolve conflicts
final gatkVersion = '4.0.6.0'
final htsjdkVersion = '2.16.0'
final testNGVersion = '6.11'
final mockitoVersion = '2.7.19'
// Get the jdk files we need to run javaDoc. We need to use these during compile, testCompile,
// test execution, and readtoolsDoc 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 {
doc {
transitive false
}
}
configurations.all {
resolutionStrategy {
// force the htsjdk version so we don't get a different one transitively or GATK
force 'com.github.samtools:htsjdk:' + htsjdkVersion
// later versions explode Hadoop
// TODO: this is the same in GATK, but we should check if they solve this issue in the future
force 'com.google.protobuf:protobuf-java:3.0.0-beta-1'
// force testng dependency so we don't pick up a different version via GenomicsDB/GATK
force 'org.testng:testng:' + testNGVersion
// be sure that mockito is in the same version for our tests
force 'org.mockito:mockito-core:' + mockitoVersion
}
// exclude all junit to avoid using it on our tests
all*.exclude group: 'junit', module: 'junit'
}
dependencies {
// use the same GATK dependency for compile and documentation
// TODO: uncomment next line when we are not using a patched GATK version (https://github.com/magicDGS/ReadTools/issues/443)
// final gatkDependency = 'org.broadinstitute:gatk:' + gatkVersion
final gatkDependency = 'com.github.bioinformagik:gatk:' + gatkVersion + "-ReadTools"
compile gatkDependency
compile group: 'com.github.samtools', name: 'htsjdk', version: htsjdkVersion
// compilation for testing
testCompile 'org.testng:testng:' + testNGVersion
testCompile 'org.mockito:mockito-core:' + mockitoVersion
// javadoc utilities; compile/test only to prevent redistribution of sdk jars
compileOnly(javadocJDKFiles)
testCompile(javadocJDKFiles)
// requires sources from GATK for the documentation
doc gatkDependency + ":sources"
}
// for managing the wrapper task
wrapper {
gradleVersion = '4.9'
}
tasks.withType(Jar) {
manifest {
attributes 'Implementation-Title': rootProject.name,
'Implementation-Version': project.version,
'Implementation-Vendor': developer + " (" + contact + ")",
'Main-Class': project.mainClassName,
'htsjdk-Version': htsjdkVersion,
'GATK-Version': gatkVersion
}
}
// test task
tasks.withType(Test) {
// tests could be always re-run
outputs.upToDateWhen { false }
String TEST_VERBOSITY = "$System.env.TEST_VERBOSITY"
useTestNG()
// TODO: set a system property for the test JVM(s)
// TODO: example -> systemProperty 'some.prop', 'value'
// set heap size for the test JVM(s)
minHeapSize = "1G"
maxHeapSize = "2G"
// TODO: set JVM arguments for the test JVM(s)
// TODO: example -> jvmArgs '-XX:MaxPermSize=256m'
if (TEST_VERBOSITY == "minimal") {
int count = 0
// listen to events in the test execution lifecycle
logger.lifecycle("Minimal test verbosity");
beforeTest { descriptor ->
count++
if( count % 100 == 0) {
logger.lifecycle("Finished "+ Integer.toString(count) + " tests")
}
}
} else {
// show the stdout/stderr of the test JVM(s) on the console
testLogging.showStandardStreams = true
// log the test that is running
beforeTest { descriptor ->
logger.lifecycle("Running Test: " + descriptor)
}
// listen to standard out and standard error of the test JVM(s)
def testOutput = ""
onOutput { descriptor, event ->
logger.lifecycle("Test: " + descriptor + " standard out/err -> " + event.message)
}
}
// logging after the tests
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)"
}
}
}
}
processTestResources {
// do not package our test data into the test jar
exclude "**/org/magicdgs/readtools/**"
}
// this task is used for have a jar file that is called just as the project name
// may be useful for uploading jar files to several places always with the same name
// and also to point to a concrete jar file as the executable
task currentJar(type: Copy){
from shadowJar
into new File(buildDir, "libs")
rename { string -> rootProject.name + ".jar"}
}
shadowJar {
zip64 true
transform(ApacheLicenseResourceTransformer)
mergeServiceFiles()
finalizedBy currentJar
}
javadoc {
options.tags = ["ReadTools.note", "ReadTools.warning"]
}
// Generate ReadTools Online Doc files (jekyll formatted)
task readtoolsDoc(type: Javadoc, dependsOn: [classes]) {
// directories
final File readtoolsDocDir = new File(buildDir, "docs/readtools")
final String readtoolsTemplates = "src/main/resources/" + documentationPackage.replaceAll("\\.", "/")
doFirst {
// make sure the output folder exists or we can create it
if (!readtoolsDocDir.exists() && !readtoolsDocDir.mkdirs()) {
throw new GradleException(String.format("Failure creating folder (%s) for ReadTools doc output in task (%s)",
readtoolsDocDir.getAbsolutePath(),
it.name));
}
final File templatesDir = new File(readtoolsTemplates);
if (! templatesDir.exists()) {
throw new GradleException(String.format("Templates folder (%s) for ReadTools doc input does not exists in task (%s)",
templatesDir.getAbsolutePath(),
it.name));
}
}
// Add all the doc sources and the main ones
final docSources = configurations.doc.collect { zipTree(it) }
source = files(docSources) + sourceSets.main.allJava
// exclude test
exclude '**/test/**'
// include all our classes, and the GATK engine and command line, which contain plugins and filters
// TODO: we should document the GATK tools included in our framework
include '**/readtools/**', '**/hellbender/engine/**', '**/cmdline/**'
// The readtoolsDoc 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
options.docletpath = classpath.asType(List)
options.doclet = documentationPackage + ".RTHelpDoclet"
outputs.dir(readtoolsDocDir)
options.destinationDirectory(readtoolsDocDir)
options.addStringOption("settings-dir", readtoolsTemplates)
options.addStringOption("index-file-extension", "yml")
options.addStringOption("output-file-extension", "md")
options.addStringOption("absolute-version", getVersion())
options.addStringOption("build-timestamp", new Date().format("dd-mm-yyyy hh:mm:ss"))
options.addStringOption("verbose")
}