8
我正在構建腳本中使用數據庫。所有的數據庫細節都在我的屬性文件中,但是我想知道如何讓用戶選擇使用哪一組細節?我正在和Phing合作,但是因爲它和Ant非常相似,我也會接受Ant的答案。在Phing(和Ant)構建腳本中選擇屬性
這裏是我的樣品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
我想爲用戶提供了一個簡單的編譯標誌來選擇要使用的數據庫。假設我有一個構建任務來檢查數據庫模式。我想提供如下構建標誌:
phing -Ddatabase=staging check-schema
這應該使用db.staging。*屬性作爲數據庫連接的詳細信息。我怎樣才能做到這樣的事情?
真棒!我不知道嵌套屬性的工作(並發現一些報告,它沒有工作,所以我從來沒有嘗試過)。至於'input',我更喜歡-D標誌,因爲我可以從外部再次編寫腳本(例如,考慮將Phing掛接到Git中,例如,Git pre-commmit)。 –