8

I'm trying to do a small project with Gradle in order to get familiar with it. I have a lot of Maven experience, so the basics seem obvious.

However, I'm having problems with the tooling. My questions is: Is there a proper Content Assist for .gradle files for Eclipse?

I tried STS, which claims it has gradle support, but when I create a new gradle project, I got a NoClassDefFoundError. So I installed a gradle plugin, I also installed Groovy (after a bunch of failed attempts I found the right version), and now I have coloring, but no content assist. I also tried Buildship - same thing. STS appears to have had "Enable DSL" for gradle in a previous version (2.9), but that option is no longer available, or I can't find it.

In short - I've tried multiple options and none of them offered a way to explore the gradle syntax, as for example an XSD-supporting XML editor would do for Maven.

Bozho
  • 588,226
  • 146
  • 1,060
  • 1,140
  • 3
    You're asking about Eclipse, but I never met anything similar even for Idea and have doubts that such a tool ever exists. If you'll fail with searching, I'd suggest you to start from reviewing classes like Project and Task in gradle api. It is easy to link their methods to gradle closures. – AdamSkywalker Dec 25 '15 at 20:43

2 Answers2

8

I know this question is old and I'm a little late, but I ran into this StackOverflow question while google searching. There is now an Eclipse plugin that supports content assist, tooltips, parse error handling, etc. It's called EGradle. The version I downloaded is 1.3.0 and as far as I know it supports Eclipse Neon and up. Hope this helps anyone in the future that happens to stop by here...

Molasses
  • 661
  • 9
  • 12
  • Good, I am using this. – Fred.Taiwan May 12 '17 at 17:19
  • To my impression, it doesn't support content assist (I'm using Gradle 4.3). In fact, it's 'Gradle setup' section doesn't work either, returning 'FAILED - gradle cannot be called to fetch at least version' upon validation attempt, no matter which options you pick. I have a valid Gradle installation I'm using daily. – badbishop Dec 03 '17 at 08:42
  • 1
    @badbishop I'm not sure what issue you're actually running into, but I just did a clean install of Eclipse Oxygen and downloaded EGradle 2.3.0 from the Eclipse Marketplace and everything works just fine (e.g. text highlighting, content assist, etc.). – Molasses Dec 19 '17 at 11:45
  • @Sal_Vader_808, I installed it and while I do have content assist when I am at the top level of the file, I don't get anything after I type `project.`, and I also don't get anything when I am inside the body of a function or closure. is that the expected behavior ? – Vic Seedoubleyew Jan 20 '18 at 13:54
  • It's called `Gradle editor` with content assist, there is another plugin called `Gradle IDE` which I didn't try. – Eric Apr 11 '18 at 21:06
  • for the sake of completeness https://github.com/de-jcup/egradle/ – Mahatma_Fatal_Error Sep 04 '21 at 09:00
2

My questions is: Is there a proper Content Assist for .gradle files for Eclipse?

Short answer is "No". As far as I know there is nothing.

The new BuildShip plugin doesn't provide editor support and as far as I know they have no plans in the near future to put work into that.

STS gradle plugin used to have a "Enable DSL Support" option, as you mention, but that option was removed because it was very very limited in what it actually could do and at the same time was a bit of a maintenance nightmare.

The Groovy Eclipse plugins provide some support for working with general .groovy code, but:

  • has no specific support for gradle
  • doesn't work well with .gradle files because it relies on project's classpath which is not the same as the classpath for the build script
  • is no longer being maintained by anyone.

There is one plugin you might want to try out. The minimalist gradle editor. I haven't tried it myself and I don't think it does content assist, but it might be your best bet at getting a little bit of support for editing .gradle files.

Kris
  • 3,898
  • 1
  • 23
  • 32
  • minimalist gradle editor has indeed support for syntax highlighting, sadly I couldn't find content assist for gradle in eclipse either – Andrés Alcarraz Mar 07 '17 at 19:33
  • Some new recommendation in 2019? I have `Buildship` and `GradleEditor` plugins installed, but sadly does not exist the autocomplete feature. – Manuel Jordan Sep 21 '19 at 14:58