I have an included grails script that I found in some random place on the Internet and it works fine for running scripts in bootable grails env. The only thing that doesn't seem to do is run my conf/*Bootstrap.groovy scripts, for example, when I run the application.
Is there another function like loadApp() and configureApp() that will do this for me?
import org.codehaus.groovy.grails.support.PersistenceContextInterceptor Ant.property(environment: "env") grailsHome = Ant.antProject.properties."env.GRAILS_HOME" includeTargets << new File("${grailsHome}/scripts/Bootstrap.groovy") target('default': "Runs scripts in the test/local directory") { if (!args) { throw new RuntimeException("[fail] This script requires an argument - the script to run.") } depends(configureProxy, packageApp, classpath) classLoader = new URLClassLoader([classesDir.toURI().toURL()] as URL[], rootLoader) Thread.currentThread().setContextClassLoader(classLoader) loadApp() configureApp() def interceptor = null def beanNames = appCtx.getBeanNamesForType(PersistenceContextInterceptor) if (beanNames && beanNames.size() == 1) { interceptor = appCtx.getBean(beanNames[0]) } try { interceptor?.init() new GroovyScriptEngine(Ant.antProject.properties."base.dir", classLoader).run("scripts/${args}.groovy", new Binding(['appCtx':appCtx])) interceptor?.flush() } catch (Exception e) { e.printStackTrace() interceptor?.clear() } finally { interceptor?.destroy() } }
danb source share