-
Notifications
You must be signed in to change notification settings - Fork 202
/
build.gradle
355 lines (315 loc) · 10.3 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
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
// Specify plugins
plugins {
id 'java-library'
id 'maven-publish'
}
// Set project info
group 'nz.ac.waikato.cms.weka'
version new File('version').text.replace("\n", "")
description 'Deep learning for WEKA'
def cuda_version = System.properties['cuda']
def valid_cuda_versions = ['10.0', '10.1', '10.2']
def is_cuda_version_valid = cuda_version in valid_cuda_versions
// Set JDK compatibility
allprojects {
sourceCompatibility = 1.8
targetCompatibility = 1.8
}
/*
* Dependency versions.
*/
ext.versions = [
'nd4j' : '1.0.0-beta7',
'dl4j' : '1.0.0-beta7',
'weka' : '3.8.4',
'junit' : '4.12',
'log4j' : '2.11.2',
'ark_tweet_nlp': '0.3.2',
'commons_lang' : '2.6',
'openblas' : '0.2.19-1.3',
'inetutils4j' : '0.0.2',
'reflections' : '0.9.10',
'lombok' : '1.18.6',
'xml_apis' : '1.0.b2'
]
publishing {
publications {
maven(MavenPublication) {
groupId = 'nz.ac.waikato.cms.weka'
artifactId = 'wekaDeeplearning4j'
version = "$version"
from components.java
}
}
}
/*
* JavaDoc task
*/
task javaDoc(type: Javadoc){
failOnError = false
source = sourceSets.main.allJava
classpath = configurations.compileClasspath
options.memberLevel = JavadocMemberLevel.PUBLIC
}
/*
* Remove copied dependencies with clean task.
*/
clean.doFirst {
delete 'lib'
}
/*
* Clean dist dir.
*/
task cleanDist(){
doLast{
delete 'dist'
}
}
/*
* Copy all compile-time dependencies into 'lib'.
*/
task copyDependencies(dependsOn: clean, type: Copy) {
from configurations.compileClasspath
into 'lib'
}
/*
* Initialize distribution directory.
*/
task mainInitDistDir(dependsOn: clean) {
doFirst {
mkdir "dist/${project.name}/lib"
}
}
/*
* Copy main package libraries.
*/
task mainCopyLibs(dependsOn: [copyDependencies, mainInitDistDir], type: Copy) {
// Copy dependencies
from('lib/') {
exclude "weka*.jar"
exclude "*cuda*"
exclude "*.pom"
exclude "*android-x86*"
exclude "*android-arm*"
exclude "*ios-arm*"
exclude "*ios-x86*"
exclude "*x86.jar"
exclude "*linux-ppc64le*.jar"
exclude "*linux-armhf*.jar"
exclude "*linux-i686*.jar"
exclude "*win-i686*.jar"
}
into "dist/${project.name}/lib"
}
/*
* Copy miscelleneous main package files.
*/
task mainCopyMisc(dependsOn: mainInitDistDir, type: Copy) {
from('./') {
include 'GenericPropertiesCreator.props'
include 'GUIEditors.props'
include 'Explorer-release.props'
include 'PluginManager.props'
include 'datasets/**'
include 'doc/**'
include 'src/main/**'
include 'src/test/resources/images/**'
exclude 'src/main/*.iml'
}
into "dist/${project.name}/"
// Needs to be called 'Explorer.props' to be found by the Weka GUI
rename "Explorer-release.props", "Explorer.props"
}
/*
* Copy Description.props file and replaces properties that are only known at build time, such as
* DATE, VERSION and ZIP_NAME.
*/
task mainCopyDescriptionProps(dependsOn: mainInitDistDir, type: Copy) {
from 'Description.props'
into "dist/${project.name}/"
def date = new Date().format("yyyy-MM-dd")
filter {
it.replaceAll("\\{DATE}", date)
.replaceAll("\\{VERSION}", "${project.version}")
.replaceAll("\\{ZIP_NAME}", "${project.name}-${project.version}.zip")
}
}
/*
* Copy the projects jar archive into the main package distribution.
*/
task mainCopyJar(dependsOn: [mainInitDistDir, assemble], type: Copy) {
from jar.archivePath
into "dist/${project.name}"
}
/*
* Zip up the main package distribution. Destination is 'dist'.
*/
task makeMainZip(dependsOn: [mainCopyJar, mainCopyDescriptionProps, mainCopyMisc, mainCopyLibs], type: Zip) {
from "dist/${project.name}"
destinationDirectory = file("dist")
}
/*
* Task to start building the main package distribution
*/
task makeMain(dependsOn: makeMainZip) {
doLast{
println("Main package distribution built. Final zip file can be found in ./dist/")
}
}
/**
* Get the excluding platforms, given a specified platform.
* E.g. given 'linux', the result would be ['windows']
* @param platform Specified platform.
* @return Platforms that are not the specified platform
*/
static def getExcludePlatform(platform) {
def platforms = ['linux', 'windows', 'macosx']
platforms.remove(platform)
return new Tuple(platforms[0], platforms[1])
}
/**
* Create a task that initilializes the cuda package distribution for a specific cuda version and
* platform.
* @param cuda_version CUDA version
* @param platform Distribution platform
* @return Task that creates the distribution for the given cuda version and platform
*/
def createCudaDirTask(cuda_version, platform) {
return tasks.create("makeCuda-$cuda_version-$platform", Copy) {
def cuda_dist_lib_dir = "dist/${project.name}-cuda-$cuda_version-$platform/lib"
doFirst {
mkdir cuda_dist_lib_dir
}
def excl_platforms = getExcludePlatform(platform)
def platform_exclude_1 = excl_platforms[0]
def platform_exclude_2 = excl_platforms[1]
from "lib"
into cuda_dist_lib_dir
exclude "*$platform_exclude_1*"
exclude "*$platform_exclude_2*"
exclude "*android-x86*"
exclude "*android-arm*"
exclude "*ios-arm*"
exclude "*ios-x86*"
exclude "*x86.jar"
exclude "*linux-ppc64le*.jar"
exclude "*linux-armhf*.jar"
exclude "*linux-i686*.jar"
exclude "*win-i686*.jar"
include "*cuda-$cuda_version*"
include "cuda-$cuda_version*"
include "cuda-platform-$cuda_version*"
}
}
/**
* Create a task that zips the cuda distribtuion for a given cuda version and platform.
* @param cuda_version CUDA version
* @param platform Distribution platform
* @return Task that zips the distribution for the given cuda version and platform
*/
def createCudaZipTask(cuda_version, platform) {
return tasks.create("makeCuda-$cuda_version-$platform-zip", Zip) {
def cuda_dist_dir = "dist/${project.name}-cuda-$cuda_version-$platform"
from cuda_dist_dir
archiveName "${project.name}-cuda-$cuda_version-$version-$platform-x86_64.zip"
destinationDirectory = file("dist")
dependsOn "makeCuda-$cuda_version-$platform"
}
}
/*
* Create the necessary cuda tasks on the fly if a cuda version was given.
*/
if (is_cuda_version_valid) {
def make_cuda_deps = [copyDependencies]
def platforms = ["linux", "windows", "macosx"]
(platforms).each { pf ->
make_cuda_deps = make_cuda_deps + "makeCuda-$cuda_version-$pf-zip"
createCudaDirTask(cuda_version, pf)
createCudaZipTask(cuda_version, pf)
}
/*
* Cuda task
*/
task makeCuda(dependsOn: make_cuda_deps) {
doLast{
println("Cuda-$cuda_version package distribution built. Final zip file can be found in ./dist/")
}
}
}
/*
* Specify dependencies.
*/
dependencies {
// Weka
implementation "nz.ac.waikato.cms.weka:weka-stable:$versions.weka"
// Deeplearning4j and ND4J
implementation "org.deeplearning4j:deeplearning4j-core:$versions.dl4j"
implementation "org.deeplearning4j:deeplearning4j-nlp:$versions.dl4j"
implementation "org.deeplearning4j:deeplearning4j-zoo:$versions.dl4j"
implementation "org.deeplearning4j:deeplearning4j-parallel-wrapper:$versions.dl4j"
implementation "org.nd4j:nd4j-native-platform:$versions.nd4j"
implementation "org.nd4j:nd4j-native-api:$versions.nd4j"
implementation "org.bytedeco.javacpp-presets:openblas-platform:$versions.openblas"
// Logging
implementation "org.apache.logging.log4j:log4j-api:$versions.log4j"
implementation "org.apache.logging.log4j:log4j-core:$versions.log4j"
implementation "org.apache.logging.log4j:log4j-slf4j-impl:$versions.log4j"
// Other
implementation ("edu.cmu.cs:ark-tweet-nlp:$versions.ark_tweet_nlp"){
exclude group: 'junit', module: 'junit'
}
implementation "commons-lang:commons-lang:$versions.commons_lang"
implementation "org.reflections:reflections:$versions.reflections"
implementation "org.projectlombok:lombok:$versions.lombok"
implementation "xml-apis:xml-apis:$versions.xml_apis"
// Tests
testImplementation group: "nz.ac.waikato.cms.weka", name: "weka-stable", version: "$versions.weka", classifier: "tests"
testImplementation "com.github.fracpete:inetutils4j:$versions.inetutils4j"
testImplementation "junit:junit:$versions.junit"
testImplementation "org.projectlombok:lombok:$versions.lombok"
// Cuda dependencies
if (cuda_version != null) {
if (is_cuda_version_valid) {
implementation "org.nd4j:nd4j-cuda-$cuda_version-platform:$versions.nd4j"
implementation "org.deeplearning4j:deeplearning4j-cuda-$cuda_version:$versions.dl4j"
if (cuda_version == "10.2") {
implementation "org.bytedeco:cuda-platform-redist:10.2-7.6-1.5.3"
}
} else {
throw new GradleException("Invalid CUDA Version: $cuda_version - Must be one of $valid_cuda_versions")
}
}
// Annotation Processors
annotationProcessor "org.projectlombok:lombok:$versions.lombok"
testAnnotationProcessor "org.projectlombok:lombok:$versions.lombok"
}
test {
maxHeapSize = "6g"
testLogging {
events "passed", "skipped", "failed"
}
if (project.hasProperty('excludeTests')) {
println "For consistency, please add your test exclusion to the travisTest task"
println "If this is an ad-hoc/short-term exclusion then ignore this message"
excludeTestsMatching project.property('excludeTests')
}
}
task travisTest(type: Test) {
maxHeapSize = "4g"
testLogging {
events "passed", "skipped", "failed"
}
filter {
// Excluded from travis due to taking too long / using too much memory and throwing OOM exception.
excludeTestsMatching 'ZooModelTest'
excludeTestsMatching 'Dl4jCNNExplorerTest'
excludeTestsMatching 'Dl4jMlpFilterTest'
}
}
/*
* Specify repositories to get the dependencies from
*/
repositories {
jcenter()
mavenCentral()
}