Created
January 30, 2013 10:34
-
-
Save lesiki/4672312 to your computer and use it in GitHub Desktop.
Grails Resources setup that automatically adds all resources in a folder
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.codehaus.groovy.grails.web.context.ServletContextHolder as SCH | |
modules = { | |
core { | |
resource url: '/resources/css/app.css', disposition: 'head' | |
resource url: '/resources/css/myapp.css', disposition: 'head' | |
resource url: '/extjs/ext-all-debug.js', dispostion: 'head' | |
getFilesForPath('/app').each { | |
resource url: it | |
} | |
} | |
} | |
def getFilesForPath(path) { | |
def webFileCachePaths = [] | |
def servletContext = SCH.getServletContext() | |
//context isn't present when testing in integration mode. -jg | |
if(!servletContext) return webFileCachePaths | |
def realPath = servletContext.getRealPath('/') | |
def appDir = new File("$realPath/$path") | |
appDir.eachFileRecurse {File file -> | |
if (file.isDirectory()) return | |
webFileCachePaths << file.path.replace(realPath, '') | |
} | |
webFileCachePaths | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment