forked from mckenfra/gsp-resources
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGspResourcesGrailsPlugin.groovy
63 lines (55 loc) · 2.48 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
import org.grails.plugin.gspresources.GspResourceLocator
import org.grails.plugin.gspresources.GspResourcePageRenderer
import org.grails.plugin.gspresources.GspResourceProcessor
class GspResourcesGrailsPlugin {
def version = "0.4.2-SNAPSHOT"
def grailsVersion = "2.0.0 > *"
def dependsOn = [
'resources': '1.1.5 > *',
'servlets': '2.0.0 > *',
'groovyPages': '2.0.0 > *'
]
def pluginExcludes = [
'src/groovy/**/test/*',
'grails-app/views/**/*',
'grails-app/controllers/**/*',
'grails-app/i18n/**/*',
'web-app/**/*',
'**/MyAppResources.groovy',
]
def author = "Stefan Kendall, Francis McKenzie"
def authorEmail = "[email protected], [email protected]"
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 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()
}
}
}