Skip to content

Instantly share code, notes, and snippets.

@tlberglund
Created October 27, 2011 20:24
Show Gist options
  • Select an option

  • Save tlberglund/1320770 to your computer and use it in GitHub Desktop.

Select an option

Save tlberglund/1320770 to your computer and use it in GitHub Desktop.
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 = 'database'
classpath = runtimeClasspath
workingDir = projectDir
main = 'org.h2.tools.RunScript'
args = ['-url', 'jdbc:h2:db/gradle_example_database;FILE_LOCK=NO', '-user', 'sa', '-script', 'create-schema-generic.sql']
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment