Generating UML class diagrams from Grails domain model

Today I tried some Grails plugins that generate UML class diagrams from the existing domain model in an Grails application. I found the following two plugins in the offical Grails plugin repository to play with.

The application I used is a small book management app that manages a couple hundred books at my workplace.

Create Domain UML plugin

First I tried the Create Domain UML plugin. This plugin is very easy to install and actually consists only of one custom Grails  script called CreateDomainUml.groovy.

To generate the diagram the yuml.me service is used. The service is totally free according to the faq section. But still his  might be a problem for some people as they cant send any source codes of there program across the internet. Well, you could run your own yuml service by buying the software and run it on an internal server.

To install the plugin into your Grails application simply enter the following command line command.

<br />
grails install-plugin create-domain-uml<br />

To generate a class diagram just enter:

<br />
grails create-domain-uml<br />

Ok enough texting. Let’s see what the plugin can do for us.

UML Class Diagram

Scroffy Top Down class diagram

UML class diagram

Orderly Top Down class diagram

The plugin creates a HTML-File and puts it into the applications root folder. On the page you see four links directing to www.yuml.me. Two of them will generate a Top Down class diagram (scroffy/orderly) as you can see above and the the other two a Right Left version of the class diagram (scroffy/orderly).

Class diagram plugin

Second up to try the Class diagram plugin. This plugin is not that easy to install. First you need to download and install Graphviz. Graphviz is an open source graph visualization software licensed under the Common Public License Version 1.0.

The installation can be triggered by executing the following command line command.

<br />
grails install-plugin class-diagram<br />

After some configuring and starting up your Grails application class diagrams can be generated by invoking http://localhost:8080/classDiagram. The result could look like the following.

UML Class Diagram

Class diagram generated by Class Diagram Plugin

The plugin comes with a mass of config possibilities I had not a deep look into. There you can change the diagrams direction (TopDown/RightLeft), appearance and level of detail.

Little downsite of the plugins is that its views depend on JQuery so might look ugly without. But it is still possible to generate the desired diagram.

Conclusion

Create Domain UML is way easier to install and has fancy but not so detailed diagrams.

Class diagram plugin is not so easy to install and has a lot configs. The diagram itself does not look so nice but is more detailed.

For my docs I used Class diagram plugin although it doesn’t look so neat. For me it was more important that the diagram shows all details of the model.

Hopefully we will see some improvements to the Create Domain UML plugin, because it is easy to use and looks nice.

About Sven Lange

I am a software engineer at Orientation in Objects in Mannheim (Germany) whose scope is mainly on web development related stuff.
This entry was posted in Grails and tagged . Bookmark the permalink.

2 Responses to Generating UML class diagrams from Grails domain model

  1. Nice, seems as if we had roughly the same idea at about the same time: http://metasieve.wordpress.com/2010/01/08/using-grails-for-creating-uml-diagrams/

  2. Pingback: Using Grails for creating UML diagrams « The MetaSieve Blog

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>