This repository has been archived by the owner on May 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 22
/
build.gradle
executable file
·354 lines (328 loc) · 12.9 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
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
// This is the top level build file for the aperture tiles core projects. Definitions / tasks that
// are shared between sub-projects need to go in here, but care should be taken not to needlessly
// pollute the global namespace. The 'settings.gradle' file that is also in this directory defines
// the sub-projects that will be built by this file, and 'properties.gradle' contains default property
// values.
// Task that reads the "buildType" string property from the command line and writes the the cloudera versions
// versions into the ext namespace (which is where build global vars go). There is a predefined build
// type in gradle.properties that will be applied if nothing is specified here.
//
// ********************************************************
// ** ANY NEW DEPLOYMENT VARIANTS NEED TO BE ADDED HERE. **
// ********************************************************
task setBuildVersions {
// Aperture tiles requires, at a minimum, Spark 1.3.0 and HBase 1.0
switch (buildType) {
// No cloudera version before 5.4.0 meets our minimum requirements
case "cdh5.4.7":
logger.info "Valid build type found - using $buildType"
project.ext { // apply project scope to vars, otherwise local to task
hadoopCommonVersion = "2.6.0-cdh5.4.7"
hadoopCoreVersion = "2.6.0-mr1-cdh5.4.7"
hbaseVersion = "1.0.0-cdh5.4.7"
htraceVersion = "3.1.0-incubating"
sparkVersion = "1.3.0-cdh5.4.7"
dependencyScalaVersion = "2.10"
scalaVersion = "2.10.3"
}
break
case "cdh5.4.1":
logger.info "Valid build type found - using $buildType"
project.ext { // apply project scope to vars, otherwise local to task
hadoopCommonVersion = "2.6.0-cdh5.4.1"
hadoopCoreVersion = "2.6.0-mr1-cdh5.4.1"
hbaseVersion = "1.0.0-cdh5.4.1"
htraceVersion = "3.1.0-incubating"
sparkVersion = "1.3.0-cdh5.4.1"
dependencyScalaVersion = "2.10"
scalaVersion = "2.10.3"
}
break
case "cdh5.4.0":
logger.info "Valid build type found - using $buildType"
project.ext { // apply project scope to vars, otherwise local to task
hadoopCommonVersion = "2.6.0-cdh5.4.0"
hadoopCoreVersion = "2.6.0-mr1-cdh5.4.0"
hbaseVersion = "1.0.0-cdh5.4.0"
sparkVersion = "1.3.0-cdh5.4.0"
dependencyScalaVersion = "2.10"
scalaVersion = "2.10.3"
}
break
default:
throw new StopExecutionException("Unsupported build type '$buildType' specified")
}
}
init.dependsOn setBuildVersions
// Generates files for the gradle wrapper (see http://www.gradle.org/docs/current/userguide/gradle_wrapper.html)
// This only needs to be run when a new version of gradle is used, and the produced files should be checked into
// source control when its done.
task wrapper(type: Wrapper) {
gradleVersion = '2.8'
}
// If we don't explicitly tell modules to inherit from the project settings, those without scala/java code will
// get misconfigured by Intellij's Gradle plugin and end up with the main and test output directories set the
// same. For some reason, IntelliJ tries to run scalac across all modules, and scalac will fail when the main
// and test output dirs are the same.
allprojects {
apply plugin: "idea"
idea {
module {
inheritOutputDirs = true
}
}
}
// General definitions pushed down to all sub-projects - this code is executed within the context
// of each subproject.
subprojects {
// Allows for eclipse project files to be generated
apply plugin: "eclipse"
// Support for reading from / writing to maven repositories
apply plugin: "maven"
// Shared group and version info. We keep build variant types in the version names so that we get
// a set of JARs for each build type written back into the maven repo.
group = "com.oculusinfo"
version = "0.7.1-$buildType"
// Maven repos to check for artifacts
repositories {
mavenLocal()
mavenCentral()
maven {
url = "http://maven.oculus.local:8080/archiva/repository/snapshots/"
}
maven {
url = "http://maven.oculus.local:8080/archiva/repository/internal/"
}
maven {
url = "https://repository.cloudera.com/artifactory/cloudera-repos"
}
// Needed for our org.restlet dependencies
maven {
url = "https://maven.restlet.com/"
}
}
// A shared function that adds hbase dependencies to the supplied project based on the build type.
// We can't use the DSL in this context, so we have to go through the lower level DependencyManager APIs.
ext.addHBaseDependencies = { config ->
if (config == null || config == "") {
config = "compile"
}
getDependencies().add(config, "org.apache.hbase:hbase-common:$hbaseVersion", {
exclude group: "asm", module: "asm"
exclude group: "org.slf4j", module: "slf4j-api"
exclude group: "org.slf4j", module: "slf4j-log4j12"
exclude group: "org.jboss.netty", module: "netty"
exclude group: "io.netty", module: "netty"
})
getDependencies().add(config, "org.apache.hbase:hbase-client:$hbaseVersion", {
exclude group: "asm", module: "asm"
exclude group: "org.slf4j", module: "slf4j-api"
exclude group: "org.slf4j", module: "slf4j-log4j12"
exclude group: "org.jboss.netty", module: "netty"
exclude group: "io.netty", module: "netty"
})
getDependencies().add(config, "org.apache.hbase:hbase-server:$hbaseVersion", {
exclude group: "asm", module: "asm"
exclude group: "org.slf4j", module: "slf4j-api"
exclude group: "org.slf4j", module: "slf4j-log4j12"
exclude group: "org.mortbay.jetty", module: "servlet-api-2.5"
exclude group: "org.jboss.netty", module: "netty"
exclude group: "io.netty", module: "netty"
})
getDependencies().add(config, "org.apache.htrace:htrace-core:$htraceVersion", {
exclude group: "asm", module: "asm"
exclude group: "org.slf4j", module: "slf4j-api"
exclude group: "org.slf4j", module: "slf4j-log4j12"
exclude group: "org.mortbay.jetty", module: "servlet-api-2.5"
exclude group: "org.jboss.netty", module: "netty"
exclude group: "io.netty", module: "netty"
})
}
// Once evaluation is done (each build file has been loaded and processed, but
// the build hasn't started) add behavior specific to web client projects.
// Client projects are flagged by a property called 'clientProject' - if that's present,
// the client behavior gets injected into the project in question.
afterEvaluate {
// Gradle/intellij don't work properly together with 1.8 at the moment,
// at least not with our code, so we have to modify java and scala
// plugins to compile with 1.7 compatibility for now, and turn off
// doclint
project.plugins.withType(JavaPlugin) {
sourceCompatibility = '1.7'
if (JavaVersion.current().isJava8Compatible()) {
allprojects {
tasks.withType(Javadoc) {
options.addStringOption('Xdoclint:none', '-quiet')
}
}
}
}
project.plugins.withType(ScalaPlugin) {
sourceCompatibility = '1.7'
if (JavaVersion.current().isJava8Compatible()) {
allprojects {
tasks.withType(Javadoc) {
options.addStringOption('Xdoclint:none', '-quiet')
}
}
}
}
if (project.ext.has("clientProject") && project.clientProject) {
// Directory constants
def TILE_CLIENT_SRC = "${rootDir}/tile-client/src"
def TILE_CLIENT_BUILD = "${rootDir}/tile-client/build"
def TILE_SERVICE_SRC = "${rootDir}/tile-service/src"
def TILE_SERVICE_BUILD = "${rootDir}/tile-service/build/libs"
def ANNOTATION_SERVICE_SRC = "${rootDir}/annotation-service/src"
def ANNOTATION_SERVICE_BUILD = "${rootDir}/annotation-service/build/libs"
def TILE_RENDERING_SRC = "${rootDir}/tile-rendering/src"
def TILE_RENDERING_BUILD = "${rootDir}/tile-rendering/build/libs"
def BINNING_UTIL_SRC = "${rootDir}/binning-utilities/src"
def BINNING_UTIL_BUILD = "${rootDir}/binning-utilities/build/libs"
def FACTORY_UTIL_SRC = "${rootDir}/factory-utilities/src"
def FACTORY_UTIL_BUILD = "${rootDir}/factory-utilities/build/libs"
def MATH_UTIL_SRC = "${rootDir}/math-utilities/src"
def MATH_UTIL_BUILD = "${rootDir}/math-utilities/build/libs"
def EXPLODED_DIR = "$buildDir/exploded"
def EXPLODED_LIBS = EXPLODED_DIR + "/WEB-INF/lib"
def APPLICATION_DIR = "$projectDir/src/main/webapp"
// Create a watch daemon thread
task watchThread() << {
Thread.start {
project.tasks.watch.execute()
}
}
// Copy client js build files into the exploded war
task copyClientJsToExploded(type: Copy) {
from fileTree(TILE_CLIENT_BUILD).include("*.js")
into EXPLODED_DIR
}
copyClientJsToExploded.inputs.dir TILE_CLIENT_BUILD
copyClientJsToExploded.outputs.dir EXPLODED_DIR
// Copy client css build files into the exploded war
task copyClientCssToExploded(type: Copy) {
from fileTree(TILE_CLIENT_BUILD).include("*.css")
into EXPLODED_DIR
}
copyClientCssToExploded.inputs.dir TILE_CLIENT_BUILD
copyClientCssToExploded.outputs.dir EXPLODED_DIR
// Copy tile-service jar files into the exploded war
task copyTileServiceToExploded(type: Copy) {
from fileTree(TILE_SERVICE_BUILD).include("*.jar")
into EXPLODED_LIBS
}
copyTileServiceToExploded.inputs.dir TILE_SERVICE_BUILD
copyTileServiceToExploded.outputs.dir EXPLODED_LIBS
// Copy factory-utilities jar into the exploded war
task copyFactoryUtilToExploded(type: Copy) {
from fileTree(FACTORY_UTIL_BUILD).include("*.jar")
into EXPLODED_LIBS
}
copyFactoryUtilToExploded.inputs.dir FACTORY_UTIL_BUILD
copyFactoryUtilToExploded.inputs.dir EXPLODED_DIR
copyFactoryUtilToExploded.outputs.dir EXPLODED_LIBS
// Copy tile-rendering jar into the exploded war
task copyTileRenderingToExploded(type: Copy) {
from fileTree(TILE_RENDERING_BUILD).include("*.jar")
into EXPLODED_LIBS
}
copyTileRenderingToExploded.inputs.dir TILE_RENDERING_BUILD
copyTileRenderingToExploded.outputs.dir EXPLODED_LIBS
// Copy binning-utilities jar into the exploded war
task copyBinningUtilToExploded(type: Copy) {
from fileTree(BINNING_UTIL_BUILD).include("*.jar")
into EXPLODED_LIBS
}
copyBinningUtilToExploded.inputs.dir BINNING_UTIL_BUILD
copyBinningUtilToExploded.outputs.dir EXPLODED_LIBS
// Copy math-utilities jar into the exploded war
task copyMathUtilToExploded(type: Copy) {
from fileTree(MATH_UTIL_BUILD).include("*.jar")
into EXPLODED_LIBS
}
copyMathUtilToExploded.inputs.dir MATH_UTIL_BUILD
copyMathUtilToExploded.outputs.dir EXPLODED_LIBS
// Copy annotation-service jar into the exploded war
task copyAnnotationServiceToExploded(type: Copy) {
from fileTree(ANNOTATION_SERVICE_BUILD).include("*.jar")
into EXPLODED_LIBS
}
copyAnnotationServiceToExploded.inputs.dir ANNOTATION_SERVICE_BUILD
copyAnnotationServiceToExploded.outputs.dir EXPLODED_LIBS
// Copy the application files into the exploded war
task copyAppToExploded(type: Copy) {
from fileTree(APPLICATION_DIR)
into EXPLODED_DIR
}
copyAppToExploded.inputs.dir APPLICATION_DIR
copyAppToExploded.outputs.dir EXPLODED_DIR
// Configure the watch task
watch {
serviceWatch {
files fileTree(TILE_SERVICE_SRC).include('**/*.java')
tasks ':tile-service:jar', 'copyTileServiceToExploded'
}
annotationWatch {
files fileTree(ANNOTATION_SERVICE_SRC).include('**/*.java')
tasks ':annotation-service:jar', 'copyAnnotationServiceToExploded'
}
factoryWatch {
files fileTree(FACTORY_UTIL_SRC).include('**/*.java')
tasks ':factory-utilities:jar', 'copyFactoryUtilToExploded'
}
renderingWatch {
files fileTree(TILE_RENDERING_SRC).include('**/*.java')
tasks ':tile-rendering:jar', 'copyTileRenderingToExploded'
}
binningWatch {
files fileTree(BINNING_UTIL_SRC).include('**/*.java')
tasks ':binning-utilities:jar', 'copyBinningUtilToExploded'
}
mathWatch {
files fileTree(MATH_UTIL_SRC).include('**/*.java')
tasks ':math-utilities:jar', 'copyMathUtilToExploded'
}
clientJsWatch {
files fileTree(TILE_CLIENT_SRC).include('**/*.js')
tasks ':tile-client:build_js', 'copyClientJsToExploded'
}
clientCssWatch {
files fileTree(TILE_CLIENT_SRC).include('**/*.css')
tasks ':tile-client:build_css', 'copyClientCssToExploded'
}
appWatch {
files fileTree(APPLICATION_DIR)
tasks 'copyAppToExploded'
}
}
// Add the tile-service and annotation-service dependencies
dependencies {
compile project(path: ":tile-service")
compile project(path: ":annotation-service")
}
// configure the war task to pick up the tile client build files
war {
from fileTree(TILE_CLIENT_BUILD).include(["*.js", "*.css"])
}
// install to ensure everything is ready for debug hotswap builds
war.dependsOn ":tile-client:install"
task explodeWar() {
doLast {
ant.unzip(src: war.archivePath, dest: EXPLODED_DIR)
}
}
explodeWar.dependsOn war
// Jetty Exploded War
// Configure the jetty run task
jettyRun {
httpPort = 8080
contextPath = project.name
scanIntervalSeconds = 1
reload = "automatic"
webAppSourceDirectory = file(EXPLODED_DIR)
}
jettyRun.dependsOn watchThread
jettyRun.dependsOn explodeWar
}
}
}