This plugin allows you to execute sql files against a configured database. It differentiates
between sql files to load data and those sql to clean data.
Using the new plugins DSL:
plugins {
id 'net.kaleidos.dwbh.gradle-fixtures-plugin' version "0.1.2"
}or
buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "net.kaleidos.dwbh:gradle-fixtures-plugin:0.1.2"
}
}
apply plugin: 'net.kaleidos.dwbh.gradle-fixtures-plugin'Although the plugin defines by default where to find the sql files to load/clean data and where to find
the database configuration file, you can use the fixtures extension to override those values:
fixtures {
loadDir = 'customDir/load'
cleanDir = 'customDir/clean'
configFile = 'customDir/db.yml'
}Here are the definitions of each field:
| Name | Description | default |
|---|---|---|
| loadDir | Where to put the fixtures SQL files | fixtures/load |
| cleanDir | Directory where to find the sql files to clean fixtures | fixtures/clean |
| configFile | File to get the database connection from | fixtures/fixtures.yml |
To include your database dependency, you can add the driver dependency in your project's dependencies block, e.g:
dependencies {
fixtures 'org.postgresql:postgresql:42.2.5'
}Once you have configured the plugin you can just execute:
./gradlew fixtures-loadAnd all sql files found at the loadDir will be executed against the
configured database. Sql files are executed in order by name.
You can execute:
./gradlew fixtures-cleanAnd all sql files found at the cleanDir will be executed against the
configured database. In this case sql files are executed in reverse order.
Thanks to Kaleidos Open Source to make this project possible.