How to run db in maven? I use ant, I did this:

... <property name="hjar" value="D:/code/untitled1/lib/hsqldb.jar"/> <property name="hclass" value="org.hsqldb.Server"/> <property name="hfile" value="-database.0 data/spittdb"/> <property name="halias" value="spitt"/> <property name="hport" value="9005"/> <target name="starthsql"> <java fork="true" classname="${hclass}" classpath="${hjar}" args="${hfile} -dbname.0 ${halias} -port ${hport}"/> </target> ... 

How do i do the same in maven?

    2 answers 2

    In maven there is a plugin that allows you to run ant task

    Add the following to pom.xml :

      <plugin> <artifactId>maven-antrun-plugin</artifactId> <version>1.8</version> <executions> <execution> <id>default-cli</id> <phase>deploy</phase> <goals> <goal>run</goal> </goals> <configuration> <target name="run-database"> <!--задачи для ant'a--> </target> </configuration> </execution> </executions> </plugin> 

    then run antrun:run -DmvnAntTarget=run-database

    • Thanks, I will try. - titsi

    Than to launch ant task-and it is better to use ready Maven plug-in :

     <plugin> <!-- current version --> <groupId>fr.avianey.mojo</groupId> <artifactId>hsqldb-maven-plugin</artifactId> <version>1.0.0</version> <!-- default value for in memory jdbc:hsqldb:hsql://localhost/xdb override only values you want to change --> <configuration> <driver>org.hsqldb.jdbcDriver</driver> <path>mem:test</path> <address>localhost</address> <name>xdb</name> <username>sa</username> <password></password> <validationQuery>SELECT 1 FROM INFORMATION_SCHEMA.SYSTEM_USERS</validationQuery> </configuration> <!-- call start and stop --> <executions> <execution> <id>start-hsqldb</id> <phase>pre-integration-test</phase> <goals> <goal>start</goal> </goals> </execution> <execution> <id>stop-hsqldb</id> <phase>post-integration-test</phase> <goals> <goal>stop</goal> </goals> </execution> </executions> </plugin>