-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathliquify.groovy
executable file
·78 lines (65 loc) · 2.04 KB
/
liquify.groovy
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
#!/usr/bin/env groovy
def liquibaseCmd = 'java -jar lib/liquibase-1.9.0.jar'
if(args.size() == 1 && args[0][0..1] == '--') {
switch(args[0]) {
case '--help':
println """
Liquibase Utility Script
Copyright © 2009 August Technology Group, LLC
NAME
\tliquify - a script that makes running Liquibase less painful
SYNOPSIS
\tliquify command [liquibase switches]
DESCRIPTION
\tliquify executes the specified Liquibase against the database described
\tin the liquibase.properties file found in the current directory. Any of
\tthe settings in the properties files can be overridden by specifying them
\tas Liquibase command line switches on the liquify command line.
PARAMETERS
\tcommand - The Liquibase command to execute. Run 'liquify --options' for
\t details.
"""
break;
case '--options':
println liquibaseCmd.execute().text
break;
}
}
else if(args.size() == 0) {
println "usage:\tliquify <command>"
println "ex:\tliquify update"
println "\tliquify generateChangeLog"
println "\tliquify --help"
println "\tliquify --options"
}
else {
def liquibaseCommand = args[0]
def defaultsFile = "liquibase.properties"
def properties = new Properties()
properties.load(new FileInputStream(defaultsFile))
def options = getOptions(args)
def password = properties.getProperty('password')
if(!password) {
password = options.password
if(!password) {
print "ENTER DATABASE PASSWORD: "
password = new BufferedReader(new InputStreamReader(System.in)).readLine()
}
}
def command = "${liquibaseCmd} --defaultsFile=${defaultsFile} --password=${password} ${liquibaseCommand} ${args.size() > 1 ? args[1..-1].join(' ') : ''}"
println command
def process = command.execute()
process.consumeProcessOutput(System.out, System.err)
}
def getOptions(args) {
def options = [:]
if(args.size() > 3) {
args[3..-1].each { arg ->
if(arg[0..1] == '--') {
def parts = arg[2..-1].tokenize('=')
options[parts[0]] = parts[1] ? parts[1] : ''
}
}
}
return options
}