Grails

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

Details

  • Type: New Feature New Feature
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: None
  • Fix Version/s: 1.0.4
  • Component/s: None
  • Labels:
    None

Description

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.

Activity

Hide
Dierk Koenig added a comment -

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.

Show
Dierk Koenig added a comment - 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.
Hide
Marcel Overdijk added a comment -

That would be an uber-generate-controller script

Show
Marcel Overdijk added a comment - That would be an uber-generate-controller script
Hide
Marcel Overdijk added a comment -

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

Show
Marcel Overdijk added a comment - 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
Hide
Marcel Overdijk added a comment -

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.

Show
Marcel Overdijk added a comment - 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.
Hide
Peter Ledbrook added a comment -

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!

Show
Peter Ledbrook added a comment - 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!
Hide
Miguel Almeida added a comment -

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.

Show
Miguel Almeida added a comment - 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.

People

Vote (6)
Watch (4)

Dates

  • Created:
    Updated:
    Resolved: