Issue Details (XML | Word | Printable)

Key: GRAILS-2946
Type: New Feature New Feature
Status: Resolved Resolved
Resolution: Fixed
Priority: Minor Minor
Assignee: Peter Ledbrook
Reporter: Dave Klein
Votes: 6
Watchers: 4
Operations

If you were logged in you would be able to see more operations.
Grails

Add script to generate all for all domain classes: uber-generate-all

Created: 14/May/08 10:40 AM   Updated: 26/Mar/09 09:48 AM   Resolved: 11/Nov/08 04:31 AM
Return to search
Component/s: None
Affects Version/s: None
Fix Version/s: 1.0.4

Time Tracking:
Not Specified

File Attachments: 1. File UberGenerate.groovy (3 kB)



 Description  « Hide

After creating several domain classes for a Grails application it is kind of tedious to have to run create-app once for each domain class. This shouldn't be too hard to automate and in fact Marcel Overdijk has already done it (http://marceloverdijk.blogspot.com/2008/05/uber-generate-all.html ). Please add his uber-generate-all script to the Grails project.

Individuals could add this themselves as described on Marcel's blog but this feature would be very helpful in giving demos at which time it is usually preferable to use the standard install.



Dierk Koenig added a comment - 04/Jul/08 07:06 AM

I feel that for demo purposes it would be even better to not use generate-all (static scaffolding) but only generate the controllers with dynamic scaffolding. That way one can evolve the domain-model on stage and any changes are instantly reflected in the running app without any need for re-triggering the generation.


Marcel Overdijk added a comment - 04/Jul/08 09:54 AM

That would be an uber-generate-controller script


Marcel Overdijk added a comment - 13/Aug/08 06:43 AM

Maybe it's even better to just improve the generate-all command.

Something like:

generate-all Book --> Generates controller and views for the Book domain class

generate-all * --> Generates controllers and views for all domain classes

generate-all Book Author --> --> Generates controller and views for both the Book and Author domain class


Marcel Overdijk added a comment - 09/Oct/08 02:33 PM

I've attached UberGenerate.groovy which does the generate-all for all the domain classes.

It's based on the mentioned blog entry but I cleaned it up a lot.


Peter Ledbrook added a comment - 11/Nov/08 04:31 AM

You can now use:

grails generate-all "*"

or

grails generate-all

and just press return when prompted for a name. Note that the quotes in the first command line are there to prevent "shell globbing", otherwise the shell will process the wildcard and add all the files in the current directory as command arguments!


Miguel Almeida added a comment - 26/Mar/09 09:48 AM

This actually works, Peter, but not for Hibernate Annotated files in the src/ directory, only for .groovy classes in the domain/ directory. Is it supposed to be like this? How can you generate all for your hibernate configured files?

Test case:

<session-factory>
<mapping class="package.Book />

</session-factory>

And a corresponding annotated Book class.