grails script 用 gorm 相关特性


原文
http://amorproximi.blogspot.com/2008/07/grails-bootstrapping.html
择录部分,

Ant.property(environment: "env")
grailsHome = Ant.antProject.properties."env.GRAILS_HOME"

includeTargets << new File("${grailsHome}/scripts/Bootstrap.groovy")


target('default': "Working edition") {
    //we need one arg, the script to run.  Follow a convention here, the arguement is the name of the
    //script to run minus the file suffix and 'Script' naming convention.  For example, running:
    //>grails ScriptRunner Merge
    //will run $PROJECT_ROOT/test/local/MergeScript.groovy with the fully bootstrapped environment
    if (!args) {
        throw new RuntimeException("[fail] This script requires an argument to the script to run.")
    }
    //copy and paste from $GRAILS_HOME/scripts/Shell.groovy
    depends(configureProxy, packageApp, classpath)
    classLoader = new URLClassLoader([classesDir.toURI().toURL()] as URL[], rootLoader)
    Thread.currentThread().setContextClassLoader(classLoader)
    loadApp()
    configureApp()
    new GroovyScriptEngine(Ant.antProject.properties."base.dir", classLoader).run("test/local/${args}Script.groovy",
            null)
}

你可能感兴趣的:(thread,html,ant,grails,groovy)