2014-09-29 30 views
0

我想爲不同品牌打包Grails應用程序。在生成war文件的同時,我想傳遞一些引用某個品牌的自定義參數,並通過加載品牌的樣式表來設置應用程序的樣式。使用Grails打包war文件時加載不同樣式表

我在線閱讀,我發現的一種方法是使用maven。我嘗試過使用maven,但在初始編譯應用程序時,我被卡住了。錯誤是

Failed to execute goal org.grails:grails-maven-plugin:2.2.1:maven-compile 
(default-maven-compile) on project foreAction: Forked Grails VM exited with error. 

我堅持要採取什麼方法現在。我搜索了上述錯誤,並嘗試了不同的解決方案,但似乎沒有任何工作。

如果沒有使用Maven有不同的方式,我願意給它一個鏡頭。

回答

1

您總是可以使用scripts/_Events.groovy掛鉤事件並替換appropraite CSS /資產。 documentation解釋瞭如何掛鉤構建事件。

你裏面scripts/_Events.groovy代碼可能是這個樣子:

// This is called after the staging dir is prepared but before the war is packaged. 
eventCreateWarStart = { name, stagingDir -> 
    // place your code here that copies your resources to the appropriate location in the staging directory. 
    Ant.copy(
    file: System.getProperty('somePassedInFile'), 
    toFile: "${stagingDir}/assets/stylesheets/whatever.css", 
    overwrite: true 
)  

}

然後你可以在源文件的值傳遞從grails prod war這樣的:

grails prod war -DsomePassedInFile=/path/to/file.css 

希望這至少可以幫助您瞭解如何實現這一目標。 (全部註銷了我的頭頂,所以要小心輸入錯誤等)

+0

非常感謝Joshua,你的解決方案就像一個魅力:) – 2014-09-30 16:07:46

+0

不用擔心,很樂意提供幫助。 – 2014-09-30 16:35:51

相關問題