I have a grails app that contains a whole mess of individual javascript files in a series of nested directories. I want to manage them via the resources plugin, but don't want to have to explicitly register each one.
Web Dir Structure
webapp
app
controller
controller1.js
controller2.js
...
model
model1.js
...
view
view1.js
what would be great is to just declare in my AppResources.groovy
file:
resource url: 'app/**/*.js'
but that doesn't work -- throws a null pointer. I've tried:
resource url: 'app/**'
but with no luck
I've thought that i would put some code in the config file that would recurse through the directory structure, but that doesn't seem to be working. Here's what I've tried:
def iterClos = {
it.eachDir( iterClos );
it.eachFile {
resource url: ${it.canonicalPath};
}
}
iterClos( new File("$grails.app.context/app") )
Unfortunately that failed as well.
Does anyone have any ideas how I could achieve this?
problem solved.
As it turns out, the idea of running code to recuse through my javascript directories works. I just had the code incorrect. Here is the code that dynamically loads my javascript files:
--AppResources.groovy
The above will cause the Resource plugin to track my javascript files. Here's what the html looks like when Resources is in debug mode:
...
Being new to Grails, it is a very welcome fact that one can put executable code within a config file!