Software Development

Eclipse Mars: Grails 3.1 with Gradle, Groovy and GSP Support

What if you want to develop Grails 3 projects with Eclipse Mars (4.5) as easy as you did with Groovy/Grails Tool Suite or previous Eclipse versions? Written and tested with Eclipse Mars.1 Release (4.5.1, build 20150924-1200) and Grails 3.1.0 M1. eclipse-mars-logo

The Eclipse landscape for Grails 3 development is a bit shady. Yes, the Getting Set Up in an IDE documentation of the currently latest version 3.1.0 M2 refers to Groovy/Grails Tool Suite as the recommended IDE for Eclipse users. However the latest GGTS to be downloaded from https://spring.io/tools/ggts is groovy-grails-tool-suite-3.6.4.RELEASE-e4.4.2-win32-x86_64.zip which is based on Eclipse Luna SR1 (4.4.2) — not Eclipse Mars.

Next to that, Groovy/Grails Tool Suite (GGTS) currently completely revolves around Grails 2 – all wizards to create taglibs, filters, controllers, services and domain classes don’t work anymore with Grails 3. Also the Grails dependency management, Grails command wizard and the rest aren’t functional anymore, since the Grails IDE plugin — which is the core component for all this — hasn’t been updated since Grails 3 came along.

Eclipse Mars was released last June and is the latest & greatest Eclipse version, so it’s no wonder you’ll be wanting to use this one as soon as possible. From the Mars website:

  • New Java IDE features, including hierarchical view of nested projects, ability to customize perspectives and speed improvements for text search.
  • Integrated tools for building and maintaining Docker containers, available from Linux Tools project.
  • Automated error reporting that allows Eclipse users to report errors directly to Eclipse projects.
  • and more…

The good news is that Eclipse Mars already comes with Gradle support — the Buildship Eclipse Plug-ins for Gradle can run all the tasks from your Grails 3 build.

So how do we make Eclipse Mars ready for Grails 3 development? In a nutshell: install Groovy support and cherry-pick some of the features of GGTS, like the GSP Editor :-)

Installing plugins

I assume you already downloaded Eclipse Mars from https://www.eclipse.org/downloads/ for your platform. Any screenshots below are for Windows, but I have no doubt the instructions will be pretty similar for other platforms.

Install all plugins below before importing an existing project — which we’ll do later on.

Installing Groovy support

We need to install the Groovy Eclipse plugin in Eclipse. Since Grails source files are for the most part made up of Groovy files, we still need some assistance from the IDE when working with them.

  1. In Eclipse, go to Help > Install New Software
  2. Use the update url http://dist.springsource.org/snapshot/GRECLIPSE/e4.5/ for Eclipse Mars (4.5.x).
  3. Select the
    Groovy Compiler 2.4 Feature and
    Groovy-Eclipse Feature.
    They both give us the Groovy support we need. Next.
     
    eclipse-install-groovy-2-4-feature
  4. Review the details. Next. Accept the terms. Next. It will install the software now.
  5. Restart Eclipse when asked.

Install Quick Text Search & GSP support

The .gsp (Groovy Server Pages) files are associated with a nice GSP Editor in GGTS, which would give syntax highlighting and auto-completion for Grails tags. In Eclipse Mars we get the default text editor; and I can tell you, that’s a pretty basic sight :-)

So, the future of Groovy/Grails Tool Suite is uncertain – and their downloads are available for only a limited time.

ggts-pivotal-limited-time

What we can do is cherry-pick some of the hard work put into GGTS. That’s…

  • the Quick Text Search – Ctrl-Shift-L baby!
  • the GSP Editor. Unfortunately I haven’t found a way to Just Get The Editor, but we have to install the Grails IDE entirely for now. This gives us a bunch of stuff we cannot use anymore (such as wizards for Grails 2 artefacts, Grails 2 installations & launch configurations etc) — but most importantly it’ll give us the GSP Editor. Tag libraries won’t be recognized correctly, but syntax highlighting of GSP files is pretty handy.
  1. Download springsource-tool-suite-3.6.4.RELEASE-e4.5-updatesite.zip from https://spring.io/tools/ggts/all and save it locally.
     
    pivotal-update-site-archives
    Why not point to an update url directly if you want to install new software, are you asking? The ZIP archive still has the Grails IDE — in the update site this has been replaced with the Spring IDE.
  2. Select the:
    Eclipse QuickSearch
    Grails IDE for Eclipse

    eclipse-install-quicksearch-and-grails-ide

  3. Restart Eclipse.

Basically, you could be done now. But while we’re at it, it’s always nice to…

Optionally, Install YAML support

Some of the configuration in a Grails 3 project is placed in application.yml – which is in YAML notation. To get better editor support for these kind of files, we still can of course still install the Spring IDE in Eclipse Mars, even through we previously installed the Grails IDE.

  1. In Eclipse, again go to Help > Install New Software
  2. Use the SpringSource Update Site for Eclipse 4.5 update url http://dist.springsource.com/release/TOOLS/update/e4.5/
  3. Select and install Spring IDE Core
     
    eclipse-install-spring-ide
  4. Restart Eclipse.

Extensions .yml and .yaml are now loaded with Spring’s Yaml Properties Editor.

Finally

We can see by by the icons that the file associations are correctly set with their respective editors e.g. when opening the Open Resource window (Ctrl-Shift-R)

open-resource-file-associations-correct1

Importing project

I assume you already created a Grails 3 project with e.g.

grails create-app helloworld

Eclipse Mars already comes with the Eclipse Buildship plugin. We need to use this plugin to “understand” our project with Gradle.

  1. Choose Import Gradle Project from the Package Explorer or File menu.
  2. “Import Gradle Project”. Select as Project Root directory: [some-dir]/helloworld. Next.
  3. “Import Options”. Select to use the Gradle wrapper (“Recommended”). Next.
  4. “Import Preview”. The project structure is checked. You might get a warning about Gradle 2.3 being used if you would import a default Grails 3.1 project. Finish.

The project should successfully be imported & visible in the Package Explorer. If you installed the Groovy-Eclipse plugin first, the project should correctly use the globally-set Groovy 2.4 compiler. No errors should be visible.

eclipse-imported-grails-gradle-project

Running the application

The Buildship plugin comes with a few views. From the Gradle Tasks view, expand your project to see all Gradle tasks.

eclipse-buildship-gradle-tasks

To run, double-click bootRun.

Although the focus immediately shifts to the Gradle Executions view for an overview of the executed Gradle tasks you won’t see much there with Gradle 2.3 – the wrapper used in a Grails 3.1 project. If you manually install a later Gradle version (e.g. 2.7) you can create new wrapper files in your project – so the Gradle Executions view can take advantage of this.

If you’ve started a Gradle task like this, it will also be available in the Run Configurations menu.

Stopping the application

Press the Stop button :-)

It’ll take a few seconds – but then the application is stopped. You’ll notice the change in the icon state.

In conclusion

That’s it. If you want to stick to Eclipse, Eclipse Mars is the best version you can get at the moment. It’s uncertain if Groovy/Grails Tool Suite will get any attention in the future or that the GSP Editor at least will find a way into it’s own project/plugin. Hopefully with above explanation you’ll be able to get up ‘n running for now with your Grails 3 projects in Eclipse Mars as you used to with Groovy/Grails Tool Suite and Grails 2. A new idea on my list at least is to automate all this with Eclipse Oomph if possible, but that’s for another time.

Any feedback is appreciated!

Ted Vinke

Ted is a Java software engineer with a passion for Web development and JVM languages and works for First8, a Java Web development company in the Netherlands.
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

6 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Alan
Alan
8 years ago

The Buildship plugin didn’t come with my download of Mars, I had to download it separately.

Ted Vinke
8 years ago

Hi Alan,

To verify I just downloaded also the Linux version (eclipse-java-mars-1-linux-gtk-x86_64.tar.gz) of Eclipse IDE for Java Developers and it’s clearly there. In Eclipse, go to Help and the 4th icon shows the Eclipse Buildship icon. It’s also the 2nd listed feature under button Installation Details, tab Features. It’s also present in the Windows 64-bit download.

I haven’t tested the Mac OS X version.

Andreas
Andreas
8 years ago

Hi Ted, thanks for this Blog. Helped me to setup eclipse so i can start hacking with Grails 3.
Cheers
Andreas

Joel Patrick Llosa
Joel Patrick Llosa
8 years ago

i got a missing gsp-classes error in my problems tab.
i commented it out in .classpath but i don’t know if it’s the right solution.
any ideas?

Keshava
Keshava
7 years ago

Getting the following error
org.gradle.tooling.GradleConnectionException: Could not install Gradle distribution from ‘https://services.gradle.org/distributions/gradle-2.9-bin.zip’.

pavithra
pavithra
7 years ago

Getting Could not resolve the Classpath Dependencies Error. Sample: Could not resolve all dependencies for configuration ‘:classpath’. > Could not resolve org.apache.commons:commons-compress:1.9. Required by: :demo1_acti:unspecified > com.nxp.grails.plugin:activiti:7.0.0-51902 > org.grails.plugins:elasticsearch:1.0.0.1 > org.elasticsearch:elasticsearch-mapper-attachments:2.6.0 > org.apache.tika:tika-parsers:1.8 > Could not resolve org.apache.commons:commons-compress:1.9. > Could not get resource ‘https://repo.grails.org/grails/core/org/apache/commons/commons-compress/1.9/commons-compress-1.9.pom’. > Could not HEAD ‘https://repo.grails.org/grails/core/org/apache/commons/commons-compress/1.9/commons-compress-1.9.pom’. > sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target > Could not resolve org.apache.commons:commons-compress:1.9. > Could not parse POM http://cien.freescale.net/archiva/repository/internal/org/apache/commons/commons-compress/1.9/commons-compress-1.9.pom > Could not download commons-parent.pom (org.apache.commons:commons-parent:34) > Could not get resource ‘https://repo.grails.org/grails/core/org/apache/commons/commons-parent/34/commons-parent-34.pom’. > Could not HEAD ‘https://repo.grails.org/grails/core/org/apache/commons/commons-parent/34/commons-parent-34.pom’. > sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException:… Read more »

Back to top button