1

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?

special0ne
  • 6,063
  • 17
  • 67
  • 107

1 Answers1

0

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>
Anton Balaniuc
  • 10,889
  • 1
  • 35
  • 53