com.googlecode.flyway.ant
Class AbstractMigrationLoadingTask

java.lang.Object
  extended by org.apache.tools.ant.ProjectComponent
      extended by org.apache.tools.ant.Task
          extended by com.googlecode.flyway.ant.AbstractFlywayTask
              extended by com.googlecode.flyway.ant.AbstractMigrationLoadingTask
All Implemented Interfaces:
Cloneable
Direct Known Subclasses:
InfoTask, MigrateTask, ValidateTask

public abstract class AbstractMigrationLoadingTask
extends AbstractFlywayTask

Base class for tasks that rely on loading migrations from the classpath.


Nested Class Summary
static class AbstractMigrationLoadingTask.LocationElement
          One <location> sub-element within the <locations> element.
static class AbstractMigrationLoadingTask.Locations
          The nested <locations> element of the task.
static class AbstractMigrationLoadingTask.PlaceholderElement
          Nested <placeholder> element inside the <placeholders> element of the migrate Ant task.
static class AbstractMigrationLoadingTask.PlaceholdersElement
          Nested <placeholders> element of the migrate Ant task.
 
Field Summary
 
Fields inherited from class com.googlecode.flyway.ant.AbstractFlywayTask
log
 
Fields inherited from class org.apache.tools.ant.Task
taskName, taskType, wrapper
 
Fields inherited from class org.apache.tools.ant.ProjectComponent
description, location, project
 
Constructor Summary
AbstractMigrationLoadingTask()
           
 
Method Summary
 void addConfiguredLocations(AbstractMigrationLoadingTask.Locations locations)
          Do not use.
 void addConfiguredPlaceholder(AbstractMigrationLoadingTask.PlaceholderElement placeholder)
          Deprecated. Use the <placeholders> element instead of adding individual <placeholder> elements directly. Will be removed in Flyway 3.0.
 void addConfiguredPlaceholders(AbstractMigrationLoadingTask.PlaceholdersElement placeholders)
          Adds placeholders from a nested <placeholders> element.
protected  void doExecute(Flyway flyway)
          Executes this task.
protected abstract  void doExecuteWithMigrationConfig(Flyway flyway)
          Executes Flyway fully configured for loading migrations.
 void setBaseDir(String baseDir)
          Deprecated. Use locations instead. Will be removed in Flyway 3.0.
 void setBasePackage(String basePackage)
          Deprecated. Use locations instead. Will be removed in Flyway 3.0.
 void setCleanOnValidationError(boolean cleanOnValidationError)
           
 void setEncoding(String encoding)
           
 void setOutOfOrder(boolean outOfOrder)
           
 void setPlaceholderPrefix(String placeholderPrefix)
           
 void setPlaceholderSuffix(String placeholderSuffix)
           
 void setSqlMigrationPrefix(String sqlMigrationPrefix)
           
 void setSqlMigrationSuffix(String sqlMigrationSuffix)
           
 void setTarget(String target)
           
 void setValidationErrorMode(String validationErrorMode)
          Deprecated. Use cleanOnValidationError instead. Will be removed in Flyway 3.0.
 
Methods inherited from class com.googlecode.flyway.ant.AbstractFlywayTask
execute, setClasspath, setClasspathref, setDriver, setPassword, setSchemas, setTable, setUrl, setUser, useValueIfPropertyNotSet, useValueIfPropertyNotSet
 
Methods inherited from class org.apache.tools.ant.Task
bindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType
 
Methods inherited from class org.apache.tools.ant.ProjectComponent
clone, getDescription, getLocation, getProject, setDescription, setLocation, setProject
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractMigrationLoadingTask

public AbstractMigrationLoadingTask()
Method Detail

addConfiguredLocations

public void addConfiguredLocations(AbstractMigrationLoadingTask.Locations locations)
Do not use. For Ant itself.

Parameters:
locations - The locations on the classpath.

setBasePackage

@Deprecated
public void setBasePackage(String basePackage)
Deprecated. Use locations instead. Will be removed in Flyway 3.0.

Parameters:
basePackage - The base package where the Java migrations are located. (default: db.migration)
Also configurable with Ant Property: ${flyway.basePackage}

setBaseDir

@Deprecated
public void setBaseDir(String baseDir)
Deprecated. Use locations instead. Will be removed in Flyway 3.0.

Parameters:
baseDir - The base directory on the classpath where the Sql migrations are located. (default: db/migration)
Also configurable with Ant Property: ${flyway.baseDir}

setEncoding

public void setEncoding(String encoding)
Parameters:
encoding - The encoding of Sql migrations. (default: UTF-8)
Also configurable with Ant Property: ${flyway.encoding}

setSqlMigrationPrefix

public void setSqlMigrationPrefix(String sqlMigrationPrefix)
Parameters:
sqlMigrationPrefix - The file name prefix for Sql migrations (default: V)
Also configurable with Ant Property: ${flyway.sqlMigrationPrefix}

setSqlMigrationSuffix

public void setSqlMigrationSuffix(String sqlMigrationSuffix)
Parameters:
sqlMigrationSuffix - The file name suffix for Sql migrations (default: .sql)
Also configurable with Ant Property: ${flyway.sqlMigrationSuffix}

setTarget

public void setTarget(String target)
Parameters:
target - The target version up to which Flyway should run migrations. Migrations with a higher version number will not be applied. (default: the latest version)
Also configurable with Ant Property: ${flyway.target}

setValidationErrorMode

@Deprecated
public void setValidationErrorMode(String validationErrorMode)
Deprecated. Use cleanOnValidationError instead. Will be removed in Flyway 3.0.

Parameters:
validationErrorMode - The action to take when validation fails.

Possible values are:

FAIL (default)
Throw an exception and fail.

CLEAN (Warning ! Do not use in produktion !)
Cleans the database.

This is exclusively intended as a convenience for development. Even tough we strongly recommend not to change migration scripts once they have been checked into SCM and run, this provides a way of dealing with this case in a smooth manner. The database will be wiped clean automatically, ensuring that the next migration will bring you back to the state checked into SCM.

This property has no effect when validationMode is set to NONE.

Also configurable with Ant Property: ${flyway.validationErrorMode}

setCleanOnValidationError

public void setCleanOnValidationError(boolean cleanOnValidationError)
Parameters:
cleanOnValidationError - Whether to automatically call clean or not when a validation error occurs. (default: false)

This is exclusively intended as a convenience for development. Even tough we strongly recommend not to change migration scripts once they have been checked into SCM and run, this provides a way of dealing with this case in a smooth manner. The database will be wiped clean automatically, ensuring that the next migration will bring you back to the state checked into SCM.

Warning ! Do not enable in production !


Also configurable with Ant Property: ${flyway.cleanOnValidationError}

setOutOfOrder

public void setOutOfOrder(boolean outOfOrder)
Parameters:
outOfOrder - Allows migrations to be run "out of order" (default: false).

If you already have versions 1 and 3 applied, and now a version 2 is found, it will be applied too instead of being ignored.

Also configurable with Ant Property: ${flyway.outOfOrder}

setPlaceholderPrefix

public void setPlaceholderPrefix(String placeholderPrefix)
Parameters:
placeholderPrefix - The prefix of every placeholder. (default: ${ )
Also configurable with Ant Property: ${flyway.placeholderPrefix}

setPlaceholderSuffix

public void setPlaceholderSuffix(String placeholderSuffix)
Parameters:
placeholderSuffix - The suffix of every placeholder. (default: } )
Also configurable with Ant Property: ${flyway.placeholderSuffix}

addConfiguredPlaceholder

@Deprecated
public void addConfiguredPlaceholder(AbstractMigrationLoadingTask.PlaceholderElement placeholder)
Deprecated. Use the <placeholders> element instead of adding individual <placeholder> elements directly. Will be removed in Flyway 3.0.

Adds a placeholder from a nested <placeholder> element. Called by Ant.

Parameters:
placeholder - The fully configured placeholder element.

addConfiguredPlaceholders

public void addConfiguredPlaceholders(AbstractMigrationLoadingTask.PlaceholdersElement placeholders)
Adds placeholders from a nested <placeholders> element. Called by Ant.

Parameters:
placeholders - The fully configured placeholders element.

doExecute

protected final void doExecute(Flyway flyway)
                        throws Exception
Description copied from class: AbstractFlywayTask
Executes this task.

Specified by:
doExecute in class AbstractFlywayTask
Parameters:
flyway - The flyway instance to operate on.
Throws:
Exception - any exception

doExecuteWithMigrationConfig

protected abstract void doExecuteWithMigrationConfig(Flyway flyway)
                                              throws Exception
Executes Flyway fully configured for loading migrations.

Parameters:
flyway - The instance of Flyway to launch.
Throws:
Exception - when the execution failed.


Copyright © 2012. All Rights Reserved.