Developer's Diary
Software development, with Terry Ebdon
12-Jul-2020 Groovy, Gradle & Eclipse

Eclipse issues

I'll be using the WindowBuilder add-on for Eclipse to create GUIs with Groovy. I want to use Gradle as my build tool, but had problems the last time I tried using WindowBuilder with Gradle. I made the mistake of creating a WindowBuilder project using the Eclipse Wizard, expecting that I'd be able to add Gradle to the project by hand.

Add GUI classes to Groovy

Today I did the exact opposite. I created a Groovy project, with gradle init and used the Eclipse 'Gradle import' wizard to add the project to the Eclipse workspace. I then used WindowBuilder to add Java SWT classes to the imported project. This worked fine. Well … kind of. I could build the project in Eclipse, using a Gradle task, and even run it. But I could never see the application's window. I could see a new JVM starting, so it looked like the code was running, just not showing itself. Dropping to a command prompt and using gradle run worked perfectly, as did the distribution zip.

Version conflicts

I'm using Eclipse IDE for Java, 2020-06, with:

  • Buildship Gradle Integration 3.0
  • Groovy Development Tools 3.9.0.SNAPSHOT
  • WindowBuilder 1.9.3

Oddly, installing WindowBuilder 1.9.3 also installs the 1.9.4 nightly build. If I delete the 1.9.4.pre version it also uninstalls version 1.9.3.

Eclipse is expecting to use Groovy version 3.0, but I'm using v2.5.11. Updating the Groovy and Spock versions, in build.gradle, gets me past that; my SWT dialogue box displays and behaves as expected.

dependencies {
// Use the latest Groovy version for building this library
implementation 'org.codehaus.groovy:groovy-all:3.0.4'
// Use the awesome Spock testing and specification framework
testImplementation 'org.spockframework:spock-core:2.0-M3-groovy-3.0'
}

Eclipse is still confused though, as it thinks I'm using an old version of Spock. It will happily run the app via Gradle, but not from the run / debug buttons. It's been a good while since I used Eclipse as my IDE. I'm sure this is just a configuration issue, but Eclipse configuration is a bit of a mess.

11-JUL-2020 👈 Top of page 👉 15-JUL-2020

© 2020 Terry Ebdon.

Find me coding on GitHub, networking on LinkedIn, answering questions on Stack Exchange and hanging out on twitter.