Ant Tasks

The Flyway Ant Tasks are provided as an AntLib.



Distributions Source


<dependency org="org.flywaydb" name="flyway-ant" rev="3.1"/>


<project ... xmlns:flyway="antlib:org.flywaydb.ant">
   <path id="flyway.lib.path">
       <!-- include all jars from the Flyway AntLib distribution -->

   <path id="flyway.classpath">
       <!-- include all jars containing jdbc drivers -->
       <!-- include all jars and directories containing sql migrations -->
       <!-- include all jars and directories containing compiled java migrations -->

   <taskdef uri="antlib:org.flywaydb.ant" resource="org/flywaydb/ant/antlib.xml"



Name Description
migrate Migrates the database
clean Drops all objects in the configured schemas
info Prints the details and status information about all the migrations
validate Validates the applied migrations against the ones available on the classpath
baseline Baselines an existing database, excluding all migrations up to and including baselineVersion
repair Repairs the metadata table


The Flyway Ant tasks can be configured in the following ways:

Attributes of the task

<flyway:migrate driver="com.myvendor.Driver" password="mySecretPwd">
        <location path="largetest/migrations1"/>
        <location path="largetest/migrations2"/>
        <placeholder name="name" value="Mr. T"/>
        <schema name="schema1"/>
        <resolver class="com.mycomp.MyMigrationResolver"/>
        <callback class="com.mycomp.MyCallback"/>

Through Ant properties

<!-- Properties are prefixed with flyway. -->
<property name="flyway.password" value="mySecretPwd"/>

<!-- List are defined as comma-separated values -->
<property name="flyway.schemas" value="schema1,schema2,schema3"/>

<!-- Individual placeholders are prefixed by flyway.placeholders. -->
<property name="flyway.placeholders.keyABC" value="valueXYZ"/>
<property name="flyway.placeholders.otherplaceholder" value="value123"/>

Through System properties

ant -Dflyway.user=myUser -Dflyway.schemas=schema1,schema2 -Dflyway.placeholders.keyABC=valueXYZ

Overriding order

System properties override Ant properties override Task attributes

Ant: migrate