-
Notifications
You must be signed in to change notification settings - Fork 17
/
build.gradle
217 lines (189 loc) · 5.09 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
/**
* Gradle Build Script.
*
* Use Gradle 5.0+.
*/
plugins {
id "java"
id "jacoco" // code coverage
id "pmd" // static code analysis
id "org.ajoberstar.grgit" version "4.1.0" // git repo information
id "org.ajoberstar.git-publish" version "3.0.0" // publish gh-pages branch
id "com.kageiit.jacobo" version "2.1.0"
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
repositories {
mavenCentral()
}
configurations {
codacy
}
dependencies {
codacy "com.codacy:codacy-coverage-reporter:4.0+"
// for explanation of dependency types, see
// https://docs.gradle.org/current/userguide/building_java_projects.html
// javax.json
implementation "javax.json:javax.json-api:1.1"
runtimeOnly "org.glassfish:javax.json:1.1"
// javax.xml (for MessageUtils)
runtimeOnly "javax.activation:activation:1.1.1"
implementation "javax.xml.bind:jaxb-api:2.3+"
runtimeOnly "org.glassfish.jaxb:jaxb-runtime:2.3+"
// javax.websocket (for notifications)
implementation "javax.websocket:javax.websocket-all:1.1"
implementation "org.glassfish.tyrus.bundles:tyrus-standalone-client:1.17"
// database drivers
runtimeOnly "mysql:mysql-connector-java:5.1.47"
runtimeOnly "org.xerial:sqlite-jdbc:3.23.1"
// ssh keys
implementation "ch.ethz.ganymed:ganymed-ssh2:262"
// nats
implementation "io.nats:java-nats-streaming:2.1.6"
implementation files("lib/MessageUtils.jar")
implementation files("lib/QWFileOutClient.jar")
// XMLVerifier uses this, but is excluded for now
// compile files("lib/cap-library-r11.jar")
testImplementation("junit:junit:4.13.1")
testImplementation("org.junit.jupiter:junit-jupiter-api:5.7.0")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.7.0")
testRuntimeOnly("org.junit.vintage:junit-vintage-engine:5.7.0")
}
sourceSets {
main {
java.excludes = ["**/XmlVerifier*"]
}
}
// show compile warnings
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8';
options.setDeprecation(true);
options.setWarnings(true);
}
// coverage reports
jacoco {
toolVersion "0.8.7"
}
jacocoTestReport {
reports {
html.enabled true
xml.enabled true
}
}
check.dependsOn jacocoTestReport
pmd {
toolVersion = "6.29.0"
ruleSets = [
file("pmd-ruleset.xml")
]
}
test {
filter {
includeTestsMatching "*Test"
}
useJUnitPlatform()
}
// clean up after tests
task testCleanup {
doLast {
delete("bin")
delete("EIDSClient_tracking.dat")
delete("heartbeat.dat")
delete("log")
delete("productIndex.db")
delete("pd_index.db")
delete("storage")
delete("T")
delete("test_index.db")
delete("test-index.db")
delete("testReceiverIndex.db")
delete("testReceiverStorage")
delete("testSenderIndex.db")
delete("testSenderPolldir")
delete("testSenderStorage")
}
}
clean.dependsOn testCleanup
test.dependsOn testCleanup
// Tasks for building releases
// create javadocs
javadoc {
excludes = ['com/isti/**'];
options.addBooleanOption('html5', true);
}
// create jar file
jar {
archiveBaseName = "ProductClient"
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
manifest {
attributes "Git-Commit": grgit.head().id
attributes "Main-Class": "gov.usgs.earthquake.distribution.Bootstrap"
}
from {
// classes and dependencies
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
}
from (".") {
// resources
include "etc/config/config.ini"
include "etc/config/regions.xml"
include "etc/schema/notificationIndex.db"
include "etc/schema/productIndex.db"
}
}
// create zip bundle
task createZip(type: Zip, dependsOn: jar) {
archiveFileName = "ProductClient.zip"
// init scripts and README
from "etc/examples/default"
// example listeners
from ("etc/examples/client/bin") { include "ExampleListener.*" }
// ProductClient.jar
from jar
}
// publish documentation and reports to gh-pages
// use after every release
gitPublish {
repoUri = "https://github.com/usgs/pdl.git"
branch = "gh-pages"
contents {
from "docs"
from createZip
from jar
from (javadoc) {
into "javadoc"
}
from (test) {
into "test"
exclude "*.bin"
exclude "*.idx"
exclude "*.xml"
}
from (jacocoTestReport) {
into "coverage"
exclude "*.xml"
}
}
}
// Tasks for TravisCI
// convert jacoco to cobertura
import com.kageiit.jacobo.JacoboTask
tasks.create("jacobo", JacoboTask, {
it.jacocoReport = file("${project.buildDir}/reports/jacoco/test/jacocoTestReport.xml")
it.coberturaReport = file("${project.buildDir}/reports/cobertura/cobertura.xml")
it.srcDirs = sourceSets.main.java.srcDirs
}).dependsOn(jacocoTestReport)
check.dependsOn jacobo
// .travis.yml uses this to upload coverage
task sendCoverageToCodacy(type: JavaExec, dependsOn: jacocoTestReport) {
description = "Upload coverage to codacy (used by TravisCI)"
main = "com.codacy.CodacyCoverageReporter"
classpath = configurations.codacy
args = [
"report",
"-l",
"Java",
"-r",
"${buildDir}/reports/jacoco/test/jacocoTestReport.xml"
]
}