-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbuild.gradle
219 lines (178 loc) · 6.97 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
//Note: this section 'buildscript` is only for the dependencies of the buildscript itself.
// See the second 'repositories' section below for the actual dependencies of this library itself
buildscript {
repositories {
mavenCentral()
}
}
plugins {
id "java-library"
id 'maven-publish'
id 'signing'
id "jacoco"
id "com.github.johnrengelman.shadow" version "4.0.4"
id "com.github.kt3k.coveralls" version "2.8.2"
id "com.github.ben-manes.versions" version "0.20.0" //used for identifying dependencies that need updating
id 'com.palantir.git-version' version '0.5.1' //version helper
}
repositories {
mavenCentral()
// Locations for finding HDF and HDFJava jar files
flatDir {
dirs 'src/main/resources/org/broadinstitute/hdf5/'
}
mavenLocal()
}
jacocoTestReport {
dependsOn test
group = "Reporting"
description = "Generate Jacoco coverage reports after running tests."
reports {
xml.required = true // coveralls plugin depends on xml format report
html.required = true
}
}
//NOTE: we ignore contracts for now
compileJava {
options.compilerArgs = ['-proc:none', '-Xlint:all','-Werror','-Xdiags:verbose']
}
compileTestJava {
options.compilerArgs = ['-proc:none', '-Xlint:all','-Werror','-Xdiags:verbose']
}
dependencies {
implementation 'org.apache.logging.log4j:log4j-slf4j-impl:2.20.0'
implementation 'org.apache.logging.log4j:log4j-api:2.20.0'
implementation 'org.apache.logging.log4j:log4j-core:2.20.0'
implementation 'org.apache.commons:commons-lang3:3.12.0'
implementation 'org.apache.commons:commons-math3:3.6.1'
implementation 'commons-io:commons-io:2.5'
api 'org.broadinstitute:gatk-native-bindings:1.0.0'
testImplementation 'org.testng:testng:6.9.6'
//This jar is not available on maven central and we want to a) compile against it and b) make it available to downstream projects
//So the workaround is to use the jar as a compile-only dependency and then mix its class files together with ours
// when making our jar. See the unzipHDF5JAR task
compileOnly name: 'jarhdf5-2.11.0'
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
final isRelease = Boolean.getBoolean("release")
version = (isRelease ? gitVersion() : gitVersion() + "-SNAPSHOT").replaceAll(".dirty", "")
logger.info("build for version:" + version)
group = 'org.broadinstitute'
defaultTasks 'jar'
// See explanation in the dependencies section for why this is done.
// This task unzips the class files from the jarhdf5 jar and dumps them
// to our build directory so that they get packaged together with our class files when we create our jar
task unzipHDF5JAR(type: Copy) {
def zipFile = file('src/main/resources/org/broadinstitute/hdf5/jarhdf5-2.11.0.jar')
def outputDir = file("${buildDir}/classes/java/main")
from zipTree(zipFile)
into outputDir
}
tasks.withType(Jar) {
manifest {
attributes 'Implementation-Title': 'HDF5-java-bindings',
'Implementation-Version': archiveVersion
}
}
//unzip the hdf5 jar before we make our own jar
jar {dependsOn unzipHDF5JAR}
javadoc {dependsOn unzipHDF5JAR}
compileTestJava{dependsOn unzipHDF5JAR}
test {
outputs.upToDateWhen { false } //tests will never be "up to date" so you can always rerun them
dependsOn unzipHDF5JAR //unzip the hdf5 jar to build path because it's a compileOnly dependency so it wont' be visible otherwise
useTestNG {}
// set heap size for the test JVM(s)
minHeapSize = "1G"
maxHeapSize = "2G"
// 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)"
}
}
}
}
wrapper {
gradleVersion = '7.6.1'
}
task javadocJar(type: Jar, dependsOn: javadoc) {
archiveClassifier.set("javadoc")
from javadoc.destinationDir
}
task sourcesJar(type: Jar) {
from sourceSets.main.allJava
archiveClassifier.set("sources")
}
publishing {
publications {
library(MavenPublication) {
from components.java
artifact javadocJar
artifact sourcesJar
pom {
name = 'HDF5 java bindings'
packaging = 'jar'
description = 'HDF5 java bindings'
url = 'http://github.com/broadinstitute/hdf5-java-bindings'
scm {
url = 'scm:[email protected]:broadinstitute/hdf5-java-bindings.git'
connection = 'scm:[email protected]:broadinstitute/hdf5-java-bindings.git'
developerConnection = 'scm:[email protected]:broadinstitute/hdf5-java-bindings.git'
}
developers {
developer {
id = "gatkdev"
name = "GATK Development Team"
email = "[email protected]"
}
}
licenses {
license {
name = 'BSD 3-Clause'
url = 'https://github.com/broadinstitute/hdf5-java-bindings/blob/master/LICENSE.TXT'
distribution = 'repo'
}
}
}
}
}
repositories {
maven {
credentials {
username = isRelease ? project.findProperty("sonatypeUsername") : project.findProperty("artifactoryUsername")
password = isRelease ? project.findProperty("sonatypePassword") : project.findProperty("artifactoryPassword")
}
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
}
}
}
// This is a hack to disable the java 8 default javadoc lint until we fix the html formatting
if (JavaVersion.current().isJava8Compatible()) {
tasks.withType(Javadoc) {
options.addStringOption('Xdoclint:none', '-quiet')
}
}
/**
* Sign non-snapshot releases with our secret key. This should never need to be invoked directly.
*/
signing {
required { isRelease && gradle.taskGraph.hasTask("publishLibraryPublicationToMavenRepository") }
sign publishing.publications.library
}