A maven plugin to start and stop an h2 instance. It creates a tcp based instance which can be configured using args
.
Add the following to your pom.xml under build->plugins tag.
::::xml
<build>
...
<plugins>
<plugin>
<groupId>net.xeric.maven</groupId>
<artifactId>h2-maven-plugin</artifactId>
<version>1.0-SNAPSHOT</version>
<configuration>
<args>
<arg>-tcp</arg>
<arg>-tcpAllowOthers</arg>
<arg>-tcpPort</arg>
<arg>5555</arg>
</args>
</configuration>
<executions>
<execution>
<phase>pre-integration-test</phase>
<goals>
<goal>h2-start</goal>
</goals>
</execution>
<execution>
<phase>post-integration-test</phase>
<goals>
<goal>h2-stop</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
<build>
<pluginRepositories>
<pluginRepository>
<id>sonatype-nexus-snapshots</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</pluginRepository>
</pluginRepositories>
If phases are not specified, the default phases are chosen.
Starts an h2 instance. This goal is bound to pre-integration-test
phase by default.
Stops the h2 instance started by h2-start
goal. This goal is bound to post-integration-test
by default.
Displays help.
Checkout a simple example in the test folder.
You can also run the goals from command line using the h2 prefix
mvn h2:h2-start
e.g. if you want to start a h2 instance right before running jetty server, you can run it as
mvn h2:h2-start jetty:run
(it assumes you have also included maven-jetty-plugin in your pom.xml)
- Writing a custom plugin from Maven: The complete reference.
- H2 Tutorial