2011-08-04 41 views
2

使用Buildr打包戰爭時可以過濾web.xml文件嗎?Buildr - 在打包戰爭中過濾web.xml

Buildr文檔:

Without much prompting, package :war picks the contents of the src/main/webapp directory and places it at the root of the WAR

我有一個佔位符或在web.xml標記中定義,我想取代它的包裝,這取決於ENV我建立在戰爭的時候。什麼是最好的方式去做呢?包裝方法有過濾選項嗎?

回答

3

您可以指示Buildr過濾src/main/webapp在你的資源,並把target/webapp下生成的文件,

filter_webapp = file("target/webapp") do |task| 
    filter('src/main/webapp/').into(task.to_s).using(
    'version' => '9999' 
).run 
end 

再用線與資源的任務的新任務(這是在包裝之前隱含地要求),

resources.enhance [filter_webapp] 

和最後封裝過濾資源,

package(:war).with(filter_webapp) 

有關過濾的更多詳細信息,請參閱http://buildr.apache.org/building.html#resources

+0

感謝Alex的回覆。雖然我還沒有得到它的工作,但將離開幾天,但將繼續這一點,當我回來 – Ross

+0

嗨亞歷克斯,這工程謝謝...之前失敗的原因是這個錯誤:ArgumentError:符號字符串在線過濾器('src/main ...)中可能不包含'\ 0'。將它縮小到我的圖像文件夾中的jpeg文件...奇怪的是,其他jpegs/gifs /等都很好。不久,當我刪除該圖像它的作品 – Ross

+0

我得到一個'ArgumentError:interning空字符串'在第二行。建設者 - 追蹤並沒有幫助我。 – koppor