forked from stefankendall/gsp-resources
-
Notifications
You must be signed in to change notification settings - Fork 5
/
GspResourcesGrailsPlugin.groovy
64 lines (56 loc) · 2.61 KB
/
GspResourcesGrailsPlugin.groovy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import org.grails.plugin.gspresources.GspResourceLocator
import org.grails.plugin.gspresources.GspResourcePageRenderer
import org.grails.plugin.gspresources.GspResourceProcessor
class GspResourcesGrailsPlugin {
def version = "0.5-SNAPSHOT"
def grailsVersion = "2.0.0 > *"
def loadAfter = ['resources', 'servlets', 'groovyPages']
def pluginExcludes = [
'src/groovy/**/test/**',
'grails-app/views/**',
'grails-app/controllers/**',
'grails-app/i18n/**',
'web-app/**',
'**/MyAppResources.groovy',
'src/docs/**'
]
def title = "GSP Resources"
def description = 'Use resources plugin to serve dynamically-built CSS and JS as static files instead of dynamic (non-cacheable) GSPs.'
def documentation = "http://mckenfra.github.com/gsp-resources/docs/guide/single.html"
def license = "APACHE"
def developers = [
[name: "Stefan Kendall", email: "stefankendall@gmail.com"],
[name: "Francis McKenzie", email: "francis.mckenzie@gmail.com"]
]
def issueManagement = [system: "GITHUB", url: "https://github.com/mckenfra/gsp-resources/issues"]
def scm = [url: "https://github.com/mckenfra/gsp-resources"]
// Inject the renderer, gsp locator, and override the resources plugin processor
def doWithSpring = {
gspResourcePageRenderer(GspResourcePageRenderer, ref("groovyPagesTemplateEngine")) { bean ->
bean.lazyInit = true
groovyPageLocator = groovyPageLocator
grailsResourceLocator = grailsResourceLocator
}
gspResourceLocator(GspResourceLocator) { bean ->
bean.lazyInit = true
groovyPageLocator = groovyPageLocator
grailsResourceLocator = grailsResourceLocator
}
// Override processor in resources plugin
grailsResourceProcessor(GspResourceProcessor) {
grailsLinkGenerator = ref('grailsLinkGenerator')
if (springConfig.containsBean('grailsResourceLocator')) {
grailsResourceLocator = ref('grailsResourceLocator')
}
gspResourcePageRenderer = ref('gspResourcePageRenderer')
gspResourceLocator = ref('gspResourceLocator')
grailsApplication = ref('grailsApplication')
}
}
// Start the resources processing if necessary - otherwise, may be done during bootstrap
def doWithDynamicMethods = { appCtx ->
if ( appCtx.grailsResourceProcessor.isStartOnPluginLoad() ) {
appCtx.grailsResourceProcessor.start()
}
}
}