0

Как запустить бд в maven? Использую ant, я делал так:

...
  <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>
...

Как мне сделать похожее в maven?

2 ответа 2

1

В maven есть плагин позволяющий запускать таски ant

В 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>

затем выполните команду antrun:run -DmvnAntTarget=run-database

1
  • Спасибо, попробую.
    – titsi
    23 авг 2016 в 13:54
1

Чем запускать ant task-и лучше пользоваться готовым Maven плагином:

<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>

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge you have read our privacy policy.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.