import org.apache.tools.ant.filters.* apply plugin: 'groovy' apply plugin: 'idea' apply plugin: 'eclipse' defaultTasks 'clean', 'prepareScripts', 'prepareServer', 'prepareTemplates', 'assembleArchive', 'test' ext.installBinDir = "${System.getProperty('user.home')}/.gvm/bin" ext.installSrcDir = "${System.getProperty('user.home')}/.gvm/src" loadConfiguration() repositories { mavenCentral() } dependencies { groovy group: 'org.codehaus.groovy', name: 'groovy', version: '2.0.5' groovy group: 'org.codehaus.groovy', name: 'groovy-templates', version: '2.0.5' compile group: 'org.vert-x', name: 'vertx-core', version: '1.3.0.final' compile group: 'org.vert-x', name: 'vertx-lang-groovy', version: '1.3.0.final' testCompile group: 'junit', name: 'junit', version: '4.11' testCompile group: 'info.cukes', name: 'cucumber-groovy', version: '1.1.1' testCompile group: 'info.cukes', name: 'cucumber-junit', version: '1.1.1' } task wrapper(type: Wrapper) { gradleVersion = '1.3' } def loadConfiguration() { def environment = hasProperty('env') ? env : 'local' ext.environment = environment println "Environment is set to: $environment" def configFile = file('config.groovy') def config = new ConfigSlurper(environment).parse(configFile.toURL()) ext.config = config } task prepareTemplates(type: Copy) { from "src/main/templates" into "build/templates" include "*.gtpl" } task prepareServer(type: Copy){ from 'src/main/groovy' into 'build/server' include 'server.groovy' filter(ReplaceTokens, tokens: [GVM_VERSION:config.gvmVersion, VERTX_VERSION:config.vertxVersion]) } task prepareScripts(type: Copy) { from 'src/main/bash' into 'build/scripts' include '**/*' filter(ReplaceTokens, tokens: [GVM_VERSION:config.gvmVersion, GVM_SERVICE:config.gvmService]) } task assembleArchive(type: Zip) { classifier = 'scripts' from "build/scripts" include "gvm*" } task cleanInstallInit(type: Delete) { delete installBinDir } task cleanInstallModules(type: Delete) { delete installSrcDir } task installInit(type: Copy, dependsOn: [cleanInstallInit, prepareScripts]) { from "build/scripts" into installBinDir include "gvm-init.sh" } task installModules(type: Copy, dependsOn: [cleanInstallModules, prepareScripts]) { from "build/scripts" into installSrcDir include "gvm-*.sh" exclude "gvm-init.sh" } task install(dependsOn: [installInit, installModules])