Skip to content

Instantly share code, notes, and snippets.

@xconnecting
Created May 27, 2013 01:17
Show Gist options
  • Save xconnecting/5654682 to your computer and use it in GitHub Desktop.
Save xconnecting/5654682 to your computer and use it in GitHub Desktop.
[Gradle] Gradle build script for executing Flyway
apply plugin: 'groovy'
apply plugin: 'eclipse'
import java.util.Properties;
import com.googlecode.flyway.commandline.Main
import com.googlecode.flyway.core.Flyway
import com.googlecode.flyway.core.util.PropertiesUtils
repositories{ mavenCentral() }
dependencies{
groovy localGroovy()
compile 'com.googlecode.flyway:flyway-core:2.1.1'
}
buildscript {
repositories { mavenCentral() }
dependencies {
classpath fileTree(dir: 'build/libs', include: '*.jar')
classpath 'com.googlecode.flyway:flyway-core:2.1'
classpath 'com.googlecode.flyway:flyway-commandline:2.1.1'
classpath 'com.h2database:h2:1.3.171'
}
}
def flyway = new Flyway()
flyway.setDataSource("jdbc:h2:file:sampledb", 'SA', '')
Properties properties = new Properties();
int consoleWidth = PropertiesUtils.getIntProperty(properties, "flyway.consoleWidth", 80);
Main.initLogging(false)
task flywayInit << {
Main.executeOperation(flyway, "init", consoleWidth);
}
task flywayClean << {
Main.executeOperation(flyway, "clean", consoleWidth);
}
task flywayMigrate << {
Main.executeOperation(flyway, "migrate", consoleWidth);
}
task flywayRepair << {
Main.executeOperation(flyway, "repqir", consoleWidth);
}
task flywayInfo << {
Main.executeOperation(flyway, "info", consoleWidth);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment