Pergunta

Eu tenho o script grails incluído o que eu encontrei em algum lugar aleatório na internet e ele funciona muito bem para disparar scripts em um grails bootstrap env. A única coisa que não parece fazer é pontapé de saída meus scripts conf/*Bootstrap.groovy como quando eu faço run-app.

Existe outra função como loadApp() e configureApp() que vai fazer isso por mim?

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()
    }
}
Foi útil?

Solução

Sim, tente

novo BootStrap (). Init ()

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top