-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
129 lines (111 loc) · 3.56 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
// Dependencies for the buildscript
buildscript {
repositories {
mavenCentral()
// gitsemver plugin repository
maven {
url "http://dl.bintray.com/palantir/releases"
}
}
// gitsemver plugin dependency
dependencies {
classpath 'com.palantir:gradle-gitsemver:0.7.2'
}
}
// PLUGINS
// add support for Java
apply plugin: 'java'
// semantic versioning
apply plugin: 'gitsemver'
// Apply the custom jacoco coverage plugin
apply from: 'gradle/jacoco.coverage.gradle'
group = 'org.magicdgs'
version semverVersion()
description = """HDF5 java Implementation"""
// library dependencies
repositories {
jcenter()
mavenCentral()
}
dependencies {
// for logging, we use the SLF4J API
compile "org.slf4j:slf4j-api:1.7.25"
// for common utilities, we use guava (eg little-endian and hashing)
compile "com.google.guava:guava:22.0"
// use TestNG for testing
testCompile "org.testng:testng:6.11"
testCompile "org.mockito:mockito-core:2.8.47"
}
// for managing the wrapper task
task wrapper(type: Wrapper) {
gradleVersion = '4.0.2'
}
tasks.withType(Javadoc) {
// the title includes the version of the API
title = "HDF5j $version API"
// add the links to the Java8 API too
options.links("http://docs.oracle.com/javase/8/docs/api/")
// add Java8 optional tags
options.tags = ["apiNote:a:API Note:",
"implSpec:a:Implementation Requirements:",
"implNote:a:Implementation Note:"]
// capture the output for the javadoc task to check if there are warnings
// from https://stackoverflow.com/questions/29519085/how-to-fail-gradle-build-on-javadoc-warnings
def capturedOutput = []
def listener = { capturedOutput << it } as StandardOutputListener
doFirst {
logging.addStandardErrorListener(listener)
logging.addStandardOutputListener(listener)
}
doLast {
logging.removeStandardOutputListener(listener)
logging.removeStandardErrorListener(listener)
// if threre is any warning, fail with a gradle exception
capturedOutput.each { e ->
if(e.toString() =~ " warning: ") {
throw new GradleException("There are javadoc warnings: javadoc failed");
}
}
}
}
// test task
tasks.withType(Test) {
// tests could be always re-run
outputs.upToDateWhen { false }
useTestNG()
// do not show the stdout/stderr of the test JVM(s) on the console
testLogging.showStandardStreams = false
// set heap size for the test JVM(s)
minHeapSize = "1G"
maxHeapSize = "2G"
// log the test that is running
beforeTest { descriptor ->
logger.lifecycle("Running Test: " + descriptor)
}
// 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)"
}
}
}
}
// for jar tasks
tasks.withType(Jar) {
// add license and notice
from(rootProject.projectDir) {
include "LICENSE.txt"
include "NOTICE.txt"
into "META-INF"
}
// add manifest information
manifest {
attributes 'Implementation-Title': rootProject.name,
'Implementation-Version': version
}
}