forked from IntelLabs/GKL
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
246 lines (213 loc) · 7.74 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
plugins {
id 'java-library'
id 'maven-publish'
id 'signing'
id 'com.palantir.git-version' version '0.5.2'
}
compileJava {
options.compilerArgs = ['-proc:none', '-Xlint:all','-Werror','-Xdiags:verbose']
}
compileTestJava {
options.compilerArgs = ['-proc:none', '-Xlint:all','-Werror','-Xdiags:verbose']
}
repositories {
mavenLocal()
mavenCentral()
maven { url "https://artifactory.broadinstitute.org/artifactory/libs-snapshot/" }
}
dependencies {
implementation 'commons-io:commons-io:2.7'
implementation 'commons-logging:commons-logging:1.2'
api 'org.broadinstitute:gatk-native-bindings:1.0.0'
api 'com.github.samtools:htsjdk:3.0.5'
testImplementation 'org.testng:testng:7.5.1'
testImplementation 'org.apache.commons:commons-lang3:3.13.0'
}
wrapper {
gradleVersion = '8.0.2'
}
//===================================================================
// build
//===================================================================
final nativeBuildDir = "$buildDir/native"
task cmakeConfig(type: Exec) {
// hide stdout, but print stderr
standardOutput = new ByteArrayOutputStream()
doFirst {mkdir nativeBuildDir}
workingDir nativeBuildDir
String c_compiler = 'gcc'
String cxx_compiler = 'g++'
String extra_c_flags = ''
if (project.hasProperty('cc')) c_compiler = project.getProperty('cc')
if (project.hasProperty('cxx')) cxx_compiler = project.getProperty('cxx')
if (project.hasProperty('cflags')) extra_c_flags = project.getProperty('cflags')
commandLine 'cmake', '-Wno-dev', '-DCMAKE_C_COMPILER=' + c_compiler,
'-DCMAKE_CXX_COMPILER=' + cxx_compiler,
'-DCMAKE_CXX_FLAGS=' + extra_c_flags ,
'-DCMAKE_C_FLAGS=' + extra_c_flags ,
'-DCMAKE_VERBOSE_MAKEFILE=ON',
projectDir
inputs.files fileTree(projectDir) {include '**/CMakeLists.txt'}
outputs.files "$nativeBuildDir/Makefile"
}
task cmakeBuild(type: Exec) {
// hide stdout, but print stderr
standardOutput = new ByteArrayOutputStream()
workingDir nativeBuildDir
commandLine 'make', 'install', '-j', Runtime.runtime.availableProcessors()
// always run this task
outputs.upToDateWhen {false}
}
task copyNativeLib(type: Copy) {
from nativeBuildDir
into "$buildDir/classes/java/main/com/intel/gkl/native"
include '*.so'
include '*.dylib'
}
task buildOnMac(type: Exec) {
String mac_host = project.ext.properties.mac_host ? project.ext.properties.mac_host : "gkl-mac"
workingDir '.'
commandLine 'scripts/buildOnMac.sh', mac_host
// TODO: restore running buildOnMac task always when uploading to Maven
onlyIf {project.hasProperty('mac') || project.hasProperty('mac_host')}
}
compileJava.finalizedBy copyNativeLib
copyNativeLib.finalizedBy buildOnMac
copyNativeLib.dependsOn cmakeBuild
cmakeConfig.dependsOn compileJava
jar.dependsOn copyNativeLib
javadoc.dependsOn copyNativeLib
// TODO: clean up dependencies using Gradle 7+ dependency mechanism
compileTestJava.dependsOn copyNativeLib
cmakeBuild.dependsOn cmakeConfig
test.dependsOn copyNativeLib
//===================================================================
// test
//===================================================================
test {
def longTestsEnabled = System.getProperty('long_tests')
def additionalJvmArgs = []
if (longTestsEnabled != null){
additionalJvmArgs.add '-Xmx24G'
}
useTestNG {
}
// propagate system properties to test JVM
systemProperties = System.getProperties()
if (project.hasProperty('debug')) {
jvmArgs('-verbose:jni', '-Xcheck:jni', '-XX:+RestoreMXCSROnJNICalls', *additionalJvmArgs)
}
else {
jvmArgs('-Xcheck:jni', '-XX:+RestoreMXCSROnJNICalls', *additionalJvmArgs)
}
testLogging {
if (!System.env.CI.toString().toBoolean()) {
events "passed", "skipped", "failed", "standardOut", "standardError"
}
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)"
}
}
}
// always rerun tests
outputs.upToDateWhen { false }
}
//===================================================================
// release
//===================================================================
final isRelease = project.hasProperty("release")
version = (isRelease ? gitVersion() : gitVersion() + "-SNAPSHOT").replaceAll(".dirty", "")
jar {
archiveBaseName = "gkl"
// include LICENSE file in jar
from "LICENSE"
}
task javadocJar(type: Jar, dependsOn: javadoc) {
archiveClassifier = 'javadoc'
from 'build/docs/javadoc'
}
task sourcesJar(type: Jar) {
from sourceSets.main.allSource
archiveClassifier = 'sources'
}
artifacts {
archives jar
archives javadocJar
archives sourcesJar
}
publishToMavenLocal.doFirst { println "Version: $version" }
publishing {
publications {
mavenJava(MavenPublication) {
groupId = 'com.intel.gkl'
artifactId = 'gkl'
from components.java
artifact sourcesJar
artifact javadocJar
pom {
name = 'Intel Genomics Kernel Library (GKL)'
description = 'Genomics compute kernels optimized for Intel Architecture'
url = 'https://github.com/Intel-HLS/GKL'
licenses {
license {
name = 'Apache License 2.0'
url = 'https://opensource.org/license/apache-2-0'
}
license {
name = 'MIT License'
url = 'https://opensource.org/licenses/MIT'
}
license {
name = 'BSD 3-Clause'
url = 'https://opensource.org/licenses/BSD-3-Clause'
}
license {
name = 'Zlib License'
url = 'https://opensource.org/licenses/Zlib'
}
}
developers {
developer {
name = "Venkata Kranthi Kumar Dhanala"
email = "[email protected]"
}
developer {
name = "Urszula Golowicz"
email = "[email protected]"
}
developer {
name = "Mateusz S. Nowak"
email = "[email protected]"
}
developer {
name = "Priya Vaidya"
email = "[email protected]"
}
}
scm {
connection = 'scm:[email protected]:Intel-HLS/GKL.git'
developerConnection = 'scm:[email protected]:Intel-HLS/GKL.git'
url = 'scm:[email protected]:Intel-HLS/GKL.git'
}
}
}
}
repositories {
maven {
def releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
def snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots/"
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
credentials {
username = project.properties["sonatypeUsername"]
password = project.properties["sonatypePassword"]
}
}
}
}
signing {
sign publishing.publications.mavenJava
}
tasks.withType(Sign) {
onlyIf { !project.version.endsWith('SNAPSHOT') }
}