-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.gradle
More file actions
113 lines (91 loc) · 3.2 KB
/
build.gradle
File metadata and controls
113 lines (91 loc) · 3.2 KB
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
apply plugin: 'java'
apply plugin: 'groovy'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'jetty'
defaultTasks 'clean', 'build'
sourceCompatibility = '1.6'
targetCompatibility = '1.6'
project.ext {
//libs
groovy = 'org.codehaus.groovy:groovy-all:2.3.6'
commonsCli = 'commons-cli:commons-cli:1.1'
log4j = 'log4j:log4j:1.2.17'
websocket = 'org.java-websocket:Java-WebSocket:1.3.1-SNAPSHOT'
unmanagedLibDir = "$projectDir/lib"
oracle = 'cn.guoyukun.jdbc:oracle-ojdbc6:11.2.0.3.0'
servlet = 'javax.servlet:servlet-api:2.5'
httpClient = 'org.codehaus.groovy.modules.http-builder:http-builder:0.7'
slf4j = 'org.slf4j:slf4j-api:1.7.5'
log4jBinding = 'org.slf4j:slf4j-log4j12:1.7.5'
jettyServer = 'org.eclipse.jetty:jetty-server:9.2.5.v20141112'
//test-libs
junit = 'junit:junit:4.8.1'
hamcrest = 'org.hamcrest:hamcrest-all:1.3'
spock = 'org.spockframework:spock-core:0.7-groovy-2.0'
//Distribution settings
distsTemplateDir = 'distribution-template'
distsBinDir = "$distsDir/bin"
//webapp config
webInfDir = 'src/main/webapp/WEB-INF'
webXml = file("$webInfDir/web.xml")
webappSrcDir = 'src/main/webapp'
}
repositories {
mavenCentral()
maven {
url 'http://code.google.com/p/google-maven-repository'
}
maven{
url 'http://codenvycorp.com/repository'
}
}
dependencies {
compile(project.ext.groovy, project.ext.commonsCli, project.ext.log4j, project.ext.websocket, project.ext.oracle,
project.ext.servlet, project.ext.httpClient, project.ext.slf4j, project.ext.log4jBinding, project.ext.jettyServer)
compile fileTree (dir: "${project.ext.unmanagedLibDir}", includes: ['*.jar'])
testCompile(project.ext.hamcrest, project.ext.junit, project.ext.spock)
}
jar {
// manifest {
// attributes.putAll(project.ext.manifest)
// }
doLast {
copy {
from (configurations.compile.asPath.split(File.pathSeparator))
into "$libsDir"
}
}
}
def prepareExecutables() {
def allLibFiles = new File("$libsDir").list().collect { "libs/$it" }
new File("$distsTemplateDir").list().each { filename ->
if(filename.startsWith('client') || filename.startsWith('server')) {
def contents = new File("$distsTemplateDir/$filename").text
new FileWriter("$distsBinDir/$filename").withWriter { writer ->
if(filename.endsWith('.sh')) {
writer.append contents.replace('%%JAVA_CLASS_PATH%%', allLibFiles.collect({"\$STREAMING_HOME/$it"}).join(":"))
}
if(filename.endsWith('.bat')) {
writer.append contents.replace('%%JAVA_CLASS_PATH%%', allLibFiles.collect({"%STREAMING_HOME%/$it"}).join(";"))
}
}
}
}
}
task distribute(type:Zip, dependsOn: [assemble]) {
doFirst {
ant.mkdir(dir:"$distsBinDir")
prepareExecutables()
}
from project.ext.distsBinDir
from ("$libsDir") { into ('libs') }
}
jettyRun {
contextPath = ''
httpPort = 9000
reload = 'automatic'
scanIntervalSeconds = 1
webAppSourceDirectory = file(project.ext.webappSrcDir)
}
build.dependsOn = ['distribute']