-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.gradle
122 lines (103 loc) · 3.29 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
// Dependencies for the buildscript
buildscript {
repositories {
mavenCentral()
}
}
// PLUGINS
plugins {
id "java"
id 'com.palantir.git-version' version "0.11.0"
}
// Apply the custom jacoco coverage plugin
apply from: 'gradle/jacoco.coverage.gradle'
group = 'org.magicdgs'
version gitVersion()
description = """HTTP/S FileSystem provider for Java NIO.2"""
// library dependencies
repositories {
jcenter()
mavenCentral()
}
def slf4jVersion = "1.7.25"
dependencies {
// for logging, we use the SLF4J API
compile "org.slf4j:slf4j-api:" + slf4jVersion
// use TestNG for testing
testCompile "org.testng:testng:6.11"
testCompile "org.mockito:mockito-core:2.8.47"
// add SLF4J implementation for testing
testCompile "org.slf4j:slf4j-simple:" + slf4jVersion
}
// for managing the wrapper task
wrapper {
gradleVersion = '4.9'
}
tasks.withType(Javadoc) {
// the title includes the version of the API
title = "jsr203-http $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
from(rootProject.projectDir) {
include "LICENSE.txt"
into "META-INF"
}
// add manifest information
manifest {
attributes 'Implementation-Title': rootProject.name,
'Implementation-Version': version
}
}