Permalink
Fetching contributors…
Cannot retrieve contributors at this time
executable file 355 lines (328 sloc) 12.9 KB
// 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
}
}
}