1. vbossica
  2. gradle-dbdeploy

Wiki

Clone wiki

gradle-dbdeploy / Home

About gradle-dbdeploy

This project is a plugin to easily call dbdeploy from a Gradle build script.

Installation

The project is currently not available in any public Maven repository (that I know of), so the installation still requires some manual steps:

  • clone the repository: hg clone https://bitbucket.org/vbossica/gradle-dbdeploy
  • install the plugin locally: gradle install

The latest snapshot release should now be available in your local Maven repository.

Usage

To use the DbDeploy plugin, include this in your build script (in this example, the database to access is Postgres):

apply plugin: 'dbdeploy'

buildscript {
  repositories {
    mavenCentral()
    mavenLocal()
  }

  dependencies {
    classpath "org.vbossica:gradle-dbdeploy:1.0-SNAPSHOT",
              "postgresql:postgresql:8.3-606.jdbc4"
  }
}

The DbDeploy plugin adds the following tasks to your project:

  • updateScripts: use DbDeploy to modify the database with update scripts.
  • importScripts: import sql scripts *as is* into the database. This feature is not officially part of the DbDeploy project but has been added for convenience.

The plugin requires the following properties to be set:

PropertyTypeDefault ValueDescription
driverstring-(required)
urlstring-(required)
userIdstring-(required)
passwordstring-
scriptDirectoryfile-(required)
changeLogTableNamestring-
dbmsstring-
outputFilefile-
templateDirfile-
encodingstringUTF-8
lineEndingstring-
delimiterstring-
delimiterTypestring-

And finally, an example:

dbdeploy {
  driver = 'org.postgresql.Driver'
  url = 'jdbc:postgresql://localhost:5432/postgres'
  userId = 'postgres'
  password = 'postgres'
}

task updateMainScripts(type: org.vbossica.gradle.UpdateScriptsTask) {
  scriptDirectory = file('src/main/sql/updates')
}

task importMainScripts(type: org.vbossica.gradle.ImportScriptsTask) {
  scriptDirectory = file('src/main/sql/packages')
}

Updated