Come faccio completamente bootstrap un ambiente graal?
-
06-09-2019 - |
Domanda
Ho lo script incluso graal che ho trovato in un posto a caso su internet e funziona abbastanza bene per la cottura degli script in un graal ENV bootstrap. L'unica cosa che non sembra di fare è dare il via i miei script conf/*Bootstrap.groovy
come quando faccio funzionare-app.
C'è un'altra funzione come loadApp()
e configureApp()
che farà questo per 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()
}
}
Soluzione
Sì, provare
nuovo bootstrap (). Init ()
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow