Using the maven exec plugin to launch hsqldb
July 31st, 2008
No comments
Below is a short snippet I use to launch hsqldb automatically for unit testing in my java projects.
Biggest limitation to the exec-maven-plugin is that it can’t run processes asynchronous. This way a running application is blocking the maven process flow. A big limitation. I think they should add an option to be able to run the process in a separate process without blocking the flow if needed.
Below is the snippet, I tried to use the windows start command. But it didn’t really work.
<!-- Execute plugin to launch hsqldb --> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>exec-maven-plugin</artifactId> <version>1.1</version> <executions> <execution> <phase>compile</phase> <goals> <goal>exec</goal> </goals> </execution> </executions> <configuration> <!-- start java -cp "c:/Documents and Settings/%USERNAME%/.m2/repository/hsqldb/hsqldb/1.8.0.7/hsqldb-1.8.0.7.jar" org.hsqldb.Server -database.0 mydb -dbname.0 xdb --> <!-- use start to execute in separate thread --> <executable>start</executable> <!-- optional --> <workingDirectory>/hsqldb</workingDirectory> <arguments> <argument>java</argument> <argument>-cp</argument> <argument>"C:/Documents and Settings/%USERNAME%/.m2/repository/hsqldb/hsqldb/1.8.0.7/hsqldb-1.8.0.7.jar"</argument> <argument>org.hsqldb.Server</argument> <argument>-database.0</argument> <argument>mydb</argument> <argument>-dbname.0</argument> <argument>xdb</argument> </arguments> </configuration> <dependencies> <dependency> <groupId>hsqldb</groupId> <artifactId>hsqldb</artifactId> <version>1.8.0.7</version> </dependency> </dependencies> </plugin> |