Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 363
Ron Stevenson Avatar asked Dec 19 '25 22:12

Ron Stevenson


1 Answers

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.

like image 159
Jeff Scott Brown Avatar answered Dec 21 '25 23:12

Jeff Scott Brown



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!