documentation/Reference/Usage/Maven Goal.md
The Flyway Maven plugin supports Maven 3.x running on Java 17.
This includes Teams & Enterprise features subject to license.
<code>pom.xml</code>
<table class="table"> <tr> <td> <pre class="prettyprint"><pluginRepositories> ... <pluginRepository> <id>redgate</id> <url>https://download.red-gate.com/maven/release</url> </pluginRepository> ... </pluginRepositories> <build> ... <plugin> <groupId><strong>com.redgate.flyway</strong></groupId> <artifactId>flyway-maven-plugin</artifactId> <version>{{ site.flywayVersion }}</version> </plugin> ... </build></pre> </td> </tr> <tr> <td> By downloading Flyway Community Maven Plugin you confirm that you have read and agree to the terms of the <a href="https://www.red-gate.com/assets/purchase/assets/subscription-license.pdf?_ga=2.265045707.556964523.1656332792-1685764737.1620948215">Redgate EULA</a>. </td> </tr> </table>To use Teams & Enterprise features, you will need the following plugin also
<table class="table"> <tr> <td> <pre class="prettyprint"><build> ... <plugin> <groupId>com.redgate.flyway</groupId> <artifactId>flyway-redgate-licensing</artifactId> <version>{{ site.flywayVersion }}</version> </plugin> ... </build></pre> </td> </tr> </table>Please note, the groupId changed at Flyway V10.0.0 from org.flywaydb.enterprise to com.redgate.flyway and published as a convenience in both locations up till Flyway V10.22.0
For older versions see Accessing Older Versions of Flyway Engine
<code>pom.xml</code>
<table class="table"> <tr> <td> <pre class="prettyprint"><build> ... <plugin> <groupId>org.flywaydb</groupId> <artifactId>flyway-maven-plugin</artifactId> <version>{{ site.flywayVersion }}</version> </plugin> ... </build></pre> </td> </tr> </table>The Flyway Maven plugin can be configured in a wide variety of following ways, which can all be combined at will.
The easiest way is to simply use the plugin's configuration section in your pom.xml:
To make it easy to work with Maven profiles and to logically group configuration, the Flyway Maven plugin also supports Maven properties:
<pre class="prettyprint"><project> ... <properties> <!-- Properties are prefixed with flyway. --> <flyway.user>myUser</flyway.user> <flyway.password>mySecretPwd</flyway.password> <!-- List are defined as comma-separated values --> <flyway.schemas>schema1,schema2,schema3</flyway.schemas> <!-- Individual placeholders are prefixed by flyway.placeholders. --> <flyway.placeholders.keyABC>valueXYZ</flyway.placeholders.keyABC> <flyway.placeholders.otherplaceholder>value123</flyway.placeholders.otherplaceholder> </properties> ... </project></pre>For storing the database user and password, Maven settings.xml files can also be used:
Both regular and encrypted settings files are supported.
To make it easy to work with cloud and containerized environments, Flyway also supports configuration via environment variables.
Configuration can also be supplied directly via the command-line using JVM system properties:
<pre class="console"><span>></span> mvn -Dflyway.user=myUser -Dflyway.schemas=schema1,schema2 -Dflyway.placeholders.keyABC=valueXYZ</pre>Config files are supported by the Flyway Maven plugin. If you are not familiar with them, check out the Flyway config file structure and settings reference first.
Flyway will search for and automatically load the <user-home>/flyway.conf config file if present.
It is also possible to point Flyway at one or more additional config files. This is achieved by
supplying the System property flyway.configFiles as follows:
To pass in multiple files, separate their names with commas:
<pre class="console"><span>></span> mvn <strong>-Dflyway.configFiles</strong>=path/to/myAlternativeConfig.conf,other.conf flyway:migrate</pre>Relative paths are relative to the directory containing your pom.xml file.
Alternatively you can also use the FLYWAY_CONFIG_FILES environment variable for this.
When set it will take preference over the command-line parameter.
By default Flyway loads configuration files using UTF-8. To use an alternative encoding, pass the system property <code>flyway.configFileEncoding</code> as follows:
<pre class="console"><span>></span> mvn <strong>-Dflyway.configFileEncoding=</strong>ISO-8859-1 flyway:migrate</pre>This is also possible via the configuration section of the plugin or Maven properties, as described above.
Alternatively you can also use the FLYWAY_CONFIG_FILE_ENCODING environment variable for this.
When set it will take preference over the command-line parameter.
The Flyway Maven plugin has been carefully designed to load and override configuration in a sensible order.
Settings are loaded in the following order (higher items in the list take precedence over lower ones):
settings.xml<user-home>/flyway.confThe means that if for example flyway.url is both present in a config file and passed as -Dflyway.url= from the command-line,
the JVM system property passed in via the command-line will take precedence and be used.