2014-09-29 33 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

相关问题