-
Notifications
You must be signed in to change notification settings - Fork 7
/
build.gradle
162 lines (142 loc) · 4.06 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
/*
* Eclipse notes: In order to build and run services via Eclipse,
* one needs to include the following directories in webapp (they
* are ignored by git):
*
* webapp/
* models/
* ak/
* 2007/
* wus/
* 2008/
* 2014/
* 2014b/
* 2018/
* ceus/
* 2008/
* 2014/
* 2018/
*
* ...with each 'year' directory being an alias to the corresponding
* git repository. One also must set Properties > Deployment Assembly
* to include the nshmp-haz project and the 'webapp' directory. Other
* default Eclipse directories such as WebContent may be deleted.
*/
apply plugin: 'war'
apply plugin: 'eclipse-wtp'
sourceCompatibility = 1.8
compileJava.options.encoding = 'UTF-8'
repositories {
mavenCentral()
}
dependencies {
providedCompile 'org.apache.tomcat:tomcat-catalina:8.0.45'
providedCompile 'javax.websocket:javax.websocket-api:1.1'
providedCompile 'com.amazonaws:aws-lambda-java-core:1.1.0'
providedCompile 'com.amazonaws:aws-java-sdk-lambda:1.11.461'
providedCompile 'com.amazonaws:aws-java-sdk-s3:1.11.579'
providedCompile 'com.amazonaws:aws-java-sdk-ec2:1.11.619'
compile project(':nshmp-haz')
}
sourceSets {
main {
java {
srcDirs = ['src']
}
resources {
srcDirs = ['src']
exclude '**/*.java'
}
}
}
ext {
getGitTag = { gitDir ->
def cmd = 'git --git-dir=' + gitDir + '/.git describe --tags'
return cmd.execute().text.replace('\n', '') ?: 'unknown'
}
propsPath = '/classes/java/main/service.properties'
/* Multi-model repository paths for version tracking */
repo_cous_2008 = '../nshm-cous-2008'
repo_cous_2014 = '../nshm-cous-2014'
repo_cous_2014b = '../nshm-cous-2014b'
repo_cous_2018 = '../nshm-cous-2018'
repo_ak_2007 = '../nshm-ak-2007'
/* Explicit model paths */
model_wus_2008 = "${repo_cous_2008}/Western US"
model_ceus_2008 = "${repo_cous_2008}/Central & Eastern US"
model_wus_2014 = "${repo_cous_2014}/Western US"
model_ceus_2014 = "${repo_cous_2014}/Central & Eastern US"
model_wus_2014b = "${repo_cous_2014b}/Western US"
model_wus_2018 = "${repo_cous_2018}/Western US"
model_ceus_2018 = "${repo_cous_2018}/Central & Eastern US"
model_ak_2007 = "${repo_ak_2007}"
/* Production models */
prod_models = [
[ model_ak_2007, 'models/ak/2007' ],
[ model_ceus_2008, 'models/ceus/2008' ],
[ model_wus_2008, 'models/wus/2008' ],
[ model_ceus_2014, 'models/ceus/2014' ],
[ model_wus_2014, 'models/wus/2014' ],
[ model_wus_2014b, 'models/wus/2014b' ],
[ model_ceus_2018, 'models/ceus/2018' ],
[ model_wus_2018, 'models/wus/2018' ],
]
}
/**
* Create war file with production models
*/
war {
enabled = true
webAppDirName = 'webapp'
/*
* Exclude existing models directory with symlinks
* to support Eclipse deployments.
*/
exclude 'models'
prod_models.each{model ->
from(model[0]) { into model[1] }
}
doFirst {
/* Record service and model versions */
writeProperties()
}
}
/**
* Create am exploded war file with production models
*/
task assembleUsgs(type: Sync) {
into "${libsDir}/exploded-war"
with war
doFirst {
/* Record service and model versions */
writeProperties()
}
}
/**
* Create a zip file of all dependencies
*/
task dependencies(type: Zip) {
baseName = "nshmp-haz-ws-dependencies"
from {
configurations.compile.collect {
it
}
}
into("java/lib")
destinationDir libsDir
}
/**
* Create properties file
*/
def writeProperties() {
def props = new Properties()
def propsFile = new File(project.buildDir.toString() + propsPath)
propsFile.createNewFile()
props.setProperty('app.version', getGitTag('.'))
props.setProperty('E2007.version', getGitTag(repo_ak_2007))
props.setProperty('E2008.version', getGitTag(repo_cous_2008))
props.setProperty('E2014.version', getGitTag(repo_cous_2014))
props.setProperty('E2014B.version', getGitTag(repo_cous_2014b))
props.setProperty('E2018.version', getGitTag(repo_cous_2018))
props.store(propsFile.newWriter(), null)
}