简体   繁体   中英

Grails create custom script that call grails commands

I'm tring to create a grails scritp ('grails create-script foo') that should receive two arguments. In it's implematition, it should call some command lines like: generate-views and generate-controllers and others commands, passing one of the parameters received.

So far I've got this: includeTargets << grailsScript("_GrailsInit")

target(foo: "The description of the script goes here!") {
    def arguments= args
    //grails create-controller arguments
}

setDefaultTarget(foo)

Anyone knows how to do this? Call a grails command inside a custom script?

Obs: I'm using grails 2.5.5

This should be as easy as including the scripts you want to use in yours via includeTargets << grailsScript() .

The available scripts are located in your Grails install directory under scripts .

In your case you might want to look at the contents of _GrailsCreateArtifacts.groovy .

Once you've included the correct script(s), all you need to do is call the corresponding closure.

Update The Generate-XXX scripts are provided by the scaffolding plugin. This plugin (in zip form) is located under the plugins directory of your Grails install. In the zip file you will find a scripts directory which has all the scripts for the plugin. Including the GenerateViews.groovy .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM