Automatically upload template files

I have a pretty standard 2.0.3 Grails application, and I executed grails install-templatesone that puts list.gsp, edit.gsp, etc. files. to the src / templates / scaffolding / directory. These files will not be automatically reloaded when they are added to them. Is there a way to get them to restart automatically, so I don’t need to stop / start the application every time I make changes? I tried looking at observableResources, but this seems to be related to the development of the plugin.

+5
source share
3 answers

You are correct that the "observed resources" mechanism applies only to plugins. The correct fix for this would be to change the kernel ScaffoldingGrailsPlugin.groovyto add

def watchedResources = "file:./src/templates/scaffolding/*"

, , JIRA. , , "" . grails create-plugin watch-scaffolding, :

import org.codehaus.groovy.grails.plugins.GrailsPlugin

class WatchScaffoldingGrailsPlugin {
    def version = "0.1"
    def grailsVersion = "2.0 > *"
    def dependsOn = [:]
    def pluginExcludes = [ "grails-app/views/error.gsp" ]

    def title = "Watch Scaffolding Plugin"
    def author = "Your name"
    def authorEmail = ""
    def description = '''\
Watches for changes to scaffolding templates and reloads dynamically-scaffolded
controllers and views.
'''
    // URL to the plugin documentation
    def documentation = "http://grails.org/plugin/watch-scaffolding"

    // watch for changes to scaffolding templates...
    def watchedResources = "file:./src/templates/scaffolding/*"

    // ... and kick the scaffolding plugin when they change
    def onChange = { event ->
        event.manager.getGrailsPlugin('scaffolding').notifyOfEvent(
            GrailsPlugin.EVENT_ON_CHANGE, null)
    }

    // rest of plugin options are no-op
    def onConfigChange = { event -> }
    def doWithWebDescriptor = { xml -> }
    def doWithSpring = { }
    def doWithDynamicMethods = { ctx -> }
    def doWithApplicationContext = { applicationContext -> }
    def onShutdown = { event -> }
}

BuildConfig.groovy

grails.plugin.location.'watch-scaffolding' = '../watch-scaffolding'

( - ), .

( Grails 2.1, , , onChange .)

+11

. :

org.codehaus.groovy.grails.scaffolding.view.
  ScaffoldingViewResolver.scaffoldedViews.clear()
+3

GRAILS-755, , , , .

Jira, :

, :

def scaffoldedView = org.codehaus.groovy.grails.scaffolding.view.ScaffoldingViewResolver.scaffoldedViews.clear()

, , , , , , .

+2

All Articles