Over a million developers have joined DZone.

Easy Grails with IntelliJ IDEA

· Java Zone

Microservices! They are everywhere, or at least, the term is. When should you use a microservice architecture? What factors should be considered when making that decision? Do the benefits outweigh the costs? Why is everyone so excited about them, anyway?  Brought to you in partnership with IBM.

This post opens a series of articles related to Groovy and Grails development with IntelliJ IDEA 8. Today we’ll discuss some general enhancements that IntelliJ IDEA has introduced to Grails support. While working with the Grails framework in IntelliJ IDEA, you don’t need to care about the complicated structure of a Grails project: IntelliJ IDEA now provides a special module type named “Grails Application”:

[img_assist|nid=6286|title=|desc=|link=none|align=left|width=640|height=524]

 

 

 

 

 

 

 

 

A Grails Application is created with all the necessary infrastructure and artifacts required by the Grails specification:

[img_assist|nid=6278|title=|desc=|link=none|align=left|width=440|height=640]

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Populate your Grails Application with the Grails elements as usual, using context menu:

 

[img_assist|nid=6279|title=|desc=|link=none|align=left|width=640|height=239]

 

 

 

 

You don’t need to care about capitalization and proper placement of the new elements: IntelliJ IDEA generates elements’ names with correct capitalization, and automatically places the new elements to the corresponding folders under the grails-app directory. For example, if you create a Grails domain class, it will be added to the domain folder, a Grails controller will be added to the controllers folder, etc.:

[img_assist|nid=6280|title=|desc=|link=none|align=left|width=598|height=640]

 

 

 

 

 

 

 

 

 

Once a Grails element is created, it is supplied with scaffolding, which can be used for two purposes:

  • Generate new elements:

    [img_assist|nid=6281|title=|desc=|link=none|align=left|width=640|height=121]

     

     

     

     

  • Navigate through the existing ones:

    [img_assist|nid=6283|title=|desc=|link=none|align=left|width=640|height=150]

 

 

 

 

IntelliJ IDEA features an easy way to run Grails targets: press Ctrl+Alt+G and specify the desired target in the Run Grails target dialog box. Note that code completion is available here: start typing the goal name, and press Ctrl+Space:

[img_assist|nid=6284|title=|desc=|link=none|align=left|width=640|height=343]

 

 

 

 

 

 

 

 

 

All output messages are sent to the console:

[img_assist|nid=6285|title=|desc=|link=none|align=left|width=640|height=326]

 

 

 

 

 

 

 

 

In the further posts, we’ll look deeper into Grails plugins management, building Grails applications, explore some Groovy and Grails subtleties, and more. Stay tuned.

 

Discover how the Watson team is further developing SDKs in Java, Node.js, Python, iOS, and Android to access these services and make programming easy. Brought to you in partnership with IBM.

Topics:

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}