Skip to content

Instantly share code, notes, and snippets.

@sdb
Created October 13, 2010 15:32
Show Gist options
  • Save sdb/624275 to your computer and use it in GitHub Desktop.
Save sdb/624275 to your computer and use it in GitHub Desktop.
liquibase-sbt-plugin configuration example
import sbt._
import com.github.sdb.sbt.liquibase._
class TestProject(info: ProjectInfo) extends DefaultProject(info) with LiquibasePlugin {
// declare the required database driver as a runtime dependency
val h2 = "com.h2database" % "h2" % "1.2.143" % "runtime"
// fetch the running mode from the system properties (dev, prd, ...)
lazy val mode = system[String]("mode").get.getOrElse(null)
// provide the parameters for running liquibase commands
lazy val liquibaseChangeLogFile = "config" / "db-changelog.xml"
lazy val liquibaseDriver = "org.h2.Driver"
// the URL depending on the mode
lazy val liquibaseUrl = mode match {
case "prd" => "jdbc:h2:tcp://dbserv:8084/~/sample"
case _ => "jdbc:h2:file:sample"
}
// the contexts to run
override lazy val liquibaseContexts = mode
// define an environment for reading props from pwd.properties
lazy val liquibaseEnv = new BasicEnvironment
{
def log = TestProject.this.log
def envBackingPath = "pwd.properties"
lazy val username = property[String]
lazy val password = property[String]
}
// provide username and password as defined in pwd.properties
override lazy val liquibaseUsername = liquibaseEnv.username.get.getOrElse(null)
override lazy val liquibasePassword = liquibaseEnv.password.get.getOrElse(null)
}
username=sa
password=blabla
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment