如何排除来自Grails的2.0 war文件的资源? [英] How to exclude a resource from the war file in Grails 2.0?
问题描述
我有建筑物战争时,不应该包括在我的Grails应用2一些特殊的内容(图片,视频等)一些测试数据。在开发时,这些文件都存储在 web应用/内容/
。所以,问题是,我该如何排除他们在打造为生产环境中的战争?
I have some test data with some special content (images, videos, etc.) in my Grails 2 application that should not be included when building the war. At development time, these files are stored in web-app/content/
. So the question is, how do I exclude them when build a war for the production environment?
在我搜索我来到翻过<一个href=\"http://www.anyware.co.uk/2005/2009/01/21/excluding-files-from-a-war-with-grails-the-right-way/\"相对=nofollow>这个博客帖子,涵盖的话题在早期版本的Grails 。不幸的是,似乎没有工作了,并评论没有帮助我满意。
During my search I came accross this blog post, covering the topic in an earlier Grails version. Unfortunately it doesn't seem to work anymore and the comments didn't help me either.
这是我曾尝试现在:
grails.war.resources = { stagingDir ->
delete { fileset(dir: "${stagingDir}/content/", includes: '*') }
}
也许我只是失去了一些东西?或者甚至有更好的方式来运送从应用单独的测试数据?
Maybe I am just missing something? Or is there even a better way to separate test-data from shipping the application?
推荐答案
是啊,我明显失去了一些东西。或者更precise有时少的信息多。更google搜索蚂蚁删除文件集的位后
我看到包括
属性德precated。在离开它之后,在内容的所有文件
目录中被删除。即使是目录结构仍然是present,这正是我想要的。
Yeah, I was obviously missing something. Or to be more precise sometimes less information is more. After a bit more of googling for ant delete fileset
I saw that the includes
attribute is deprecated. After leaving it out, all files in the content
directory were removed. Even the directory structure is still present, which is exactly what I wanted.
所以,我现在的解决方案是:
So my solution for now is:
grails.war.resources = { stagingDir ->
delete { fileset dir: "${stagingDir}/content/" }
}
编辑:
据我所知Grails使用蚂蚁引擎盖下,所以蚂蚁删除任务是看的东西。所以我想,如果你想删除空的子目录太多,这将是(但不选中):
As far as I know grails uses ant under the hood, so the Ant Delete Task is the thing to look at. So I guess if you want to delete the empty subdirectories too, it would be (not checked though):
delete(includeEmptyDirs: true) { fileset dir: "${stagingDir}/content/" }
或如果u要删除内容
文件夹本身只是:
or if u want to delete the content
folder itself just:
delete(dir: "${stagingDir}/content/")
这篇关于如何排除来自Grails的2.0 war文件的资源?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!