-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
80 lines (65 loc) · 2.29 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
import java.util.concurrent.TimeUnit
apply plugin: 'java'
println """\
Welcome to Gradle $gradle.gradleVersion - http://www.gradle.org
Gradle home is set to: $gradle.gradleHomeDir
Gradle user directory is set to: $gradle.gradleUserHomeDir
Base directory: $projectDir
Running script ${relativePath(buildFile)}
"""
task buildAll(dependsOn: [':client:npm_run_build', ':server:build'])
task postIt(type: StopVerticle) {
mustRunAfter ':it'
}
task unzipDist(type: Copy, dependsOn: 'buildAll') {
from tarTree('server/build/distributions/myserver-3.3.2.tar')
into 'server/build/distributions/'
}
task preIt(type: StartVerticle, dependsOn: ['unzipDist']) {
ready 'Succeeded in deploying verticle'
finalizedBy postIt
directory "server/build/distributions/myserver-3.3.2"
}
task it(dependsOn: ['preIt', ':client:npm_run_e2e']) {
}
// adapted from https://github.com/marc0der/gradle-spawn-plugin
class StartVerticle extends DefaultTask {
String ready
String directory
static Process process;
@TaskAction
def spawnProcess() {
def String classpath;
def libs = new File("$directory/lib").listFiles().toList().collect {it.absolutePath}
if (System.getenv("TRAVIS") == null) {
classpath = libs.join(';')
} else {
classpath = libs.join(':')
}
println(classpath)
ProcessBuilder builder = new ProcessBuilder("""java -classpath $classpath -Dfile.encoding=UTF-8 io.vertx.core.Launcher run io.vertx.example.ValueCompassVerticle""".split(' '))
builder.redirectErrorStream(true)
builder.directory(new File("$directory"))
process = builder.start()
InputStream stdout = process.getInputStream()
BufferedReader reader = new BufferedReader(new
InputStreamReader(stdout))
def String line
while ((line = reader.readLine()) != null) {
println line
if (line.contains(ready)) {
println "server is ready"
break;
}
}
}
}
class StopVerticle extends DefaultTask {
@TaskAction
def killProcess() {
while (StartVerticle.process.isAlive()) {
StartVerticle.process.destroyForcibly();
StartVerticle.process.waitFor(10, TimeUnit.SECONDS);
}
}
}