H2 Gradle Plugin


(james.r.carr) #1

I’ve created an H2 plugin that we have been using successfully on separate projects lately. You can find the project page at

http://jamescarr.github.com/h2-gradle-plugin/

This basically allows you to add a code block to your gradle script that defines databases in h2 and initialization scripts:

h2 {
    tcpPort = 9092
    webPort = 8082
      awesomeDatabase {
        scripts = [
             'src/test/resources/cars.sql'
           , 'src/test/resources/init-data.sql'
        ]
    }
        reallyAwesomeDatabase {
        scripts = [
             'src/test/resources/cars.sql'
           , 'src/test/resources/init-data.sql'
        ]
    }
}

And provides two handy tasks (h2start and h2stop).

I’m working on cleaning up the documentation and providing an example project that connects to h2 using embedded tomcat and jetty instances, but just wanted to get it out there so others can give it a try (and fill up my issues queue). :slight_smile:

Thanks, James