Reputation: 3635
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?
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.
This is what I have tried for now:
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?
Upvotes: 3
Views: 3511
Reputation: 3635
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/" }
}
EDIT: 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/" }
or if u want to delete the content
folder itself just:
delete(dir: "${stagingDir}/content/")
Upvotes: 7