Commits

David Carr committed eeb98c5

Issue #4: fix loading of new page resource files

  • Participants
  • Parent commits dff19de

Comments (0)

Files changed (2)

File PageResourcesGrailsPlugin.groovy

  */
 
 import org.grails.plugin.resources.page.PageResourcesInterceptor
+import org.springframework.core.io.FileSystemResource
 
 class PageResourcesGrailsPlugin {
     def version = "0.1.2-SNAPSHOT"
 
     def scm = [ url: "https://github.com/davidmc24/grails-page-resources/" ]
 
+    def watchedResources = [
+        "file:./web-app/pages/**/*.*" // Watch for page resource changes
+    ]
+
     def doWithSpring = {
         pageResourcesInterceptor(PageResourcesInterceptor)
     }
+
+    def onChange = { event ->
+        def manager = event.manager
+        def resourcesPlugin = manager.getGrailsPlugin('resources').@plugin
+        if (event.source instanceof FileSystemResource) {
+            log.info("Scheduling reload of modules due to change of file $event.source.file")
+            resourcesPlugin.triggerReload {
+                event.application.mainContext.grailsResourceProcessor.reloadModules()
+            }
+        } else {
+            log.info("Scheduling reload of modules due to change of $event.source.name")
+            resourcesPlugin.triggerReload {
+                event.application.mainContext.grailsResourceProcessor.reloadModules()
+            }
+        }
+    }
 }

File src/docs/guide/releaseNotes.gdoc

 
 h4. 0.1.2 (Release TBD)
 * Fixed IllegalArgumentException on unsupported files in pages directory ( "Issue #2":https://github.com/davidmc24/grails-page-resources/issues/2 )
+* Fixed loading of new page resource files ( "Issue #4":https://github.com/davidmc24/grails-page-resources/issues/4 )
 
 h4. 0.1.1 (Released 7-18-2012)
 * Fixed IllegalArgumentException on Windows ( "Issue #1":https://github.com/davidmc24/grails-page-resources/issues/1 )