-
Notifications
You must be signed in to change notification settings - Fork 19
/
database.gradle
41 lines (34 loc) · 929 Bytes
/
database.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
apply plugin: 'java'
repositories {
mavenCentral()
}
dependencies {
runtime 'com.h2database:h2:1.3.153'
}
task createDatabaseScript {
group = 'database'
doLast {
def fileName = 'starth2'
if(System.properties['os.name'].startsWith('Windows')) {
fileName += '.bat'
}
def file = new File(projectDir, fileName)
file.withPrintWriter { pw ->
pw.print("java -cp ${sourceSets.main.runtimeClasspath.asPath} org.h2.tools.Server")
}
file.setExecutable(true)
}
}
task startDatabase(type: JavaExec) {
group = 'database'
workingDir = projectDir
main = 'org.h2.tools.Server'
classpath = runtimeClasspath
}
task buildSchema(type: JavaExec) {
group = 'workshop'
classpath = runtimeClasspath
workingDir = projectDir
main = 'org.h2.tools.RunScript'
args = ['-url', 'jdbc:h2:db/liquibase_workshop;FILE_LOCK=NO', '-user', 'sa', '-script', 'create-schema-generic.sql']
}