forked from usgs/nshmp-haz
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
172 lines (156 loc) · 4.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
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
apply plugin: 'java'
apply plugin: 'jacoco'
apply plugin: 'eclipse-wtp'
sourceCompatibility = 1.8
compileJava.options.encoding = 'UTF-8'
jacoco {
toolVersion = '0.8.4'
}
repositories {
jcenter()
}
dependencies {
compile('com.google.guava:guava:26.0-jre') {
/* skip optional guava dependencies */
transitive = false
}
compile 'com.google.code.gson:gson:2.8.5'
testCompile 'junit:junit:4.12'
}
sourceSets {
main {
java {
srcDirs = ['src']
}
resources {
srcDirs = ['src']
exclude '**/*.java'
}
}
test {
java {
srcDirs = ['test']
}
resources {
srcDirs = ['test']
exclude '**/*.java'
}
}
}
ext {
projectName = 'nshmp-haz'
/*
* The git-dir option gets the correct tag when
* build is called from nshmp-haz-ws.
*/
gitCommand = 'git --git-dir=../nshmp-haz/.git describe --tags'
gitTag = gitCommand.execute().text.replace('\n', '') ?: 'unknown'
gitLink = '<a href="https://github.com/usgs/nshmp-haz">' + gitTag +'</a>'
propsPath = '/resources/main/app.properties'
docTitle = projectName + ': ' + gitLink
docFooter = '<div style="float: left; font-size: 16px; text-align: right; ' +
'padding: 10px; width: 100%; box-sizing: border-box; background-color: #f9f9f9">' +
'<b><a href="https://www.usgs.gov" target="_top">U.S. Geological Survey</a></b> ' +
'– National Seismic Hazard Model Project ' +
'(<a href="https://earthquake.usgs.gov/hazards/" target="_top">NSHMP</a>) ' +
'– <a href="https://github.com/usgs/nshmp-haz/blob/master/LICENSE.md" ' +
'target="_top">License</a> | <b>' + gitLink + '</b></div>'
docOut = findProperty('javadoc_loc')
thinJar = false
}
test {
filter {
includeTestsMatching "gov.usgs.earthquake.nshmp.data.*"
includeTestsMatching "gov.usgs.earthquake.nshmp.geo.*"
includeTestsMatching "gov.usgs.earthquake.nshmp.gmm.*"
//includeTestsMatching "gov.usgs.earthquake.nshmp.eq.model.peer.PeerTests"
}
}
jacocoTestReport {
reports {
xml.enabled true
html.enabled true
}
afterEvaluate {
classDirectories = files(classDirectories.files.collect {
fileTree(
dir: it,
exclude: ['**/etc/**'])
})
}
}
check.dependsOn jacocoTestReport
javadoc {
options.setUse(true)
options.author(true)
options.version(true)
options.windowTitle(projectName)
options.docTitle(docTitle)
options.encoding('UTF-8')
options.docEncoding('UTF-8')
options.charSet('UTF-8')
options.bottom(docFooter)
options.addStringOption('Xdoclint:none', '-quiet')
options.links(
'https://docs.oracle.com/javase/8/docs/api/',
'https://google.github.io/guava/releases/23.0/api/docs/',
'https://google.github.io/gson/apidocs/')
include 'gov/usgs/earthquake/nshmp/**'
exclude 'gov/usgs/earthquake/nshmp/etc/**'
exclude 'gov/usgs/earthquake/nshmp/internal/**'
exclude '**/Scratch*'
doLast {
if (docOut) {
delete docOut
copy {
from 'build/docs/javadoc'
into docOut
}
copy {
from 'etc/resources/docs'
into docOut + '/resources'
}
}
}
}
/*
* The default jar task automatically builds a fat jar and adds
* a properties file with the application version. Note that
* 'git describe' only works when running gradle from the command
* line so version values in eclipse builds will empty. Use thinJar
* task to skip dependencies.
*/
jar {
doFirst {
/* possible fat jar */
if (rootProject.name == projectName && !thinJar) {
from { configurations.compile.collect {
it.isDirectory() ? it : zipTree(it).matching {
exclude { it.path.contains('META-INF') }
}
}}
}
/*
* Possibly record app version. The creation of this file
* on each build causes the classpath to appear changed so
* Gradle reruns tests, even though no code has changed.
*/
def props = new Properties()
def propsFile = new File(project.buildDir.toString() + propsPath)
if (propsFile.exists()) {
props.load(propsFile.newReader())
} else {
propsFile.createNewFile()
}
if (!gitTag.equals(props.getProperty('app.version'))) {
props.setProperty('app.version', gitTag)
props.store(propsFile.newWriter(), null)
}
}
}
task thinJar(type: Jar) {
doFirst {
thinJar = true
}
with jar
}