grailsantcode-generationgant

How to create a CLI script for code generation, like what "grails create-controller" does


I would like to create a command line tool to generate some java source code...e.g., a controller class, service class, and a DTO class. I've been trying to find the scripts for CreateController.groovy (from grails), but I've had no luck finding that script. Any help would be much appreciated. I think it might be done with Gant?


Solution

  • I've been trying to find the scripts for CreateController.groovy (from grails), but I've had no luck finding that script.

    You haven't indicated what version of Grails you want to use and that may be relevant. For recent versions of Grails there is not a CreateController.groovy but the create-controller command is defined at https://github.com/grails/grails-profile-repository/blob/master/profiles/web/commands/create-controller.yml.

    I think it might be done with Gant?

    Not since Grails 2. If you are using Grails 1 or 2, then a Gant script might be what you are looking for. For Grails 2.5.6, the command is defined at https://github.com/grails/grails-core/blob/bd7cc10e17d34f20cedce979724f0e3bacd4cdb4/grails-scripts/src/main/scripts/CreateController.groovy.