I am working with databases in my build script. All the database details are in my properties file, but I was wondering how I could easily have the user choose which set of details to use? I am working with Phing, but because it is so similar to Ant I'll also accept Ant answers.
Here's my sample build.properties
:
# Connection details for the dev database
db.dev.hostname=localhost
db.dev.database=foo
db.dev.username=foo_user
db.dev.password=foo_password
# Connection details for the staging database
db.staging.hostname=some.remote.server
db.staging.database=bar
db.staging.username=bar_user
db.staging.password=bar_password
I would like to offer the user a simple build flag to choose which database to use. Suppose I have a build task to check a database schema. I would like to offer a build flag like so:
phing -Ddatabase=staging check-schema
That should use the db.staging.* properties for the database connection details. How can I achieve such a thing?
input
, I prefer -D flags because I can script that again from the outside (think about hooking Phing into yout Git pre-commmit for example). – Defect