forked from linux-china/jenv
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle
59 lines (46 loc) · 1.61 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
import org.apache.tools.ant.filters.ReplaceTokens
apply plugin: 'groovy'
apply plugin: 'idea'
defaultTasks 'clean', 'prepareResources', 'prepareCommands', 'prepareJenvCommands', 'assembleArchive'
ext.installDir = "${System.getProperty('user.home')}/.jenv"
loadConfiguration()
repositories {
mavenCentral()
}
configurations {
sshAntTask
}
dependencies {
compile group: 'org.codehaus.groovy', name: 'groovy', version: '2.4.3'
compile group: 'org.apache.ant', name: 'ant', version: '1.9.0'
}
@SuppressWarnings("GroovyAssignabilityCheck")
def loadConfiguration() {
def environment = hasProperty('env') ? env : 'dev'
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 prepareResources(type: Copy) {
from 'src/main/resources'
into 'build/jenv'
include '**/*'
filter(ReplaceTokens, tokens: [JENV_VERSION: config.jenvVersion, JENV_SERVICE: config.jenvService])
}
task prepareCommands(type: Copy) {
from 'src/main/scripts/bin'
into 'build/jenv/bin'
filter(ReplaceTokens, tokens: [JENV_VERSION: config.jenvVersion, JENV_SERVICE: config.jenvService])
}
task prepareJenvCommands(type: Copy, dependsOn: [prepareResources, prepareCommands]) {
from 'src/main/scripts/commands'
into 'build/jenv/commands'
filter(ReplaceTokens, tokens: [JENV_VERSION: config.jenvVersion, JENV_SERVICE: config.jenvService])
}
task assembleArchive(type: Zip, dependsOn: [prepareJenvCommands]) {
classifier = config.jenvVersion
from "build/jenv"
include "**/*"
}