Skip to content

Commit

Permalink
Added -Ddatabase.classpath and -Ddatabase.driver Also available in da…
Browse files Browse the repository at this point in the history
…tabase.properties driver= classpath=
  • Loading branch information
ErwinvanBrandwijk committed Apr 6, 2011
1 parent 16516fa commit cb98da8
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
16 changes: 12 additions & 4 deletions howto.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,30 @@ To use groovy-liquibase you'll need [Gradle](http://www.gradle.org/).
2) Command line $: gradle build

3) You have two options to set configuration:
Database connection is also configured in liquibase.gradle on runtime (default mysql)

1 Create file database.properties

#database.properties

url: "yourDatabaseUrl"
username: "yourDatabaseUser"
password: "yourPassword"
url: yourDatabaseUrl
username: yourDatabaseUser
password: yourPassword
change.log.file: changelog.groovy
working.dir: path (OPTIONEEL)
classpath: driver.jar (OPTIONEEL)
driver: driverclass oracle.jdbc.OracleDriver (OPTIONEEL)

2 Use system configurations at each command

gradle -q -b liquibase.gradle update \
-Ddatabase.url=jdbc:mysql://localhost/test \
-Ddatabase.username=root \
-Ddatabase.password=admin \
-Dchange.log.file=changelog.groovy
-Dchange.log.file=changelog.groovy \
-Dworking.dir=changelog.groovy \ (OPTIONEEL)
-Ddatabase.driver=changelog.groovy (OPTIONEEL)
-Ddatabase.classpath=changelog.groovy (OPTIONEEL)

4) change.log.file is the master file where all the database changes are located.

Expand Down
13 changes: 11 additions & 2 deletions liquibase.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ database.username = System.properties['database.username'] ?: properties.usernam
database.password = System.properties['database.password'] ?: properties.password
database.changeLogFile = System.properties['change.log.file'] ?: properties['change.log.file']
database.workingDir = System.properties['working.dir'] ?: properties['working.dir']
database.classpath = System.properties['database.classpath'] ?: properties['classpath']
database.driver = System.properties['database.driver'] ?: properties['driver']


task generateChangeLog << {
Expand Down Expand Up @@ -170,11 +172,18 @@ def runLiquibase(String command) {
}

def runLiquibase(List argList) {
def stdArgs = ["--url=${project.database.url}", "--username=${project.database.username}", "--password=${project.database.password}"]
def contexts = System.properties['liquibase.contexts']
def stdArgs = ["--url=${project.database.url}", "--username=${project.database.username}", "--password=${project.database.password}""]
if(project.database.changeLogFile) {
stdArgs << "--changeLogFile=${project.database.changeLogFile}"
}
def contexts = System.properties['liquibase.contexts']
if(project.database.driver) {
stdArgs << "--driver=${project.database.driver}"
}
if(project.database.classpath) {
stdArgs << "--classpath=${project.database.classpath}"
}
if(contexts) {
stdArgs << "--contexts=${contexts}"
}
Expand Down

0 comments on commit cb98da8

Please sign in to comment.