`
dellsoft
  • 浏览: 114542 次
  • 性别: Icon_minigender_1
  • 来自: 济南
社区版块
存档分类
最新评论

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)
}
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics