special0ne
special0ne

Reputation: 6263

How to create a SQL dump using sql-maven-plugin

I use the sql-maven-plugin to handle the database before and after the maven tests ran. The examples are pretty straight forward in regards to dropping/ creating schema, populating.

How can I create a SQL dump of the db using this plugin?

Upvotes: 1

Views: 1099

Answers (1)

Anton Balaniuc
Anton Balaniuc

Reputation: 11749

It looks like there is no way to do it with sql-maven-plugin. The main purpose of that plugin is to execute SQL statements . mysql-dump is a separate tool for creating backups. One of the possible solutions in this case is to use exec-maven-plugin

<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>exec-maven-plugin</artifactId>
  <version>1.2.1</version>
  <executions>
      <execution>
          <id>mysql-dump-create</id>
          <phase>clean</phase>
          <goals>
              <goal>exec</goal>
          </goals>
      </execution>
  </executions>
  <configuration>
      <executable>${path_to_mysqldump}</executable>
      <workingDirectory>${workdir}</workingDirectory>
      <arguments>
          <argument>--user=${user}</argument>
          <argument>--password=${password}</argument>
          <argument>--host=${host}</argument>
          <argument>--result-file=${name}</argument>
          <argument>${db}</argument>
      </arguments>
  </configuration>
</plugin>

Upvotes: 0

Related Questions