Seb Charrot Seb Charrot - 11 months ago 153
Java Question

IntelliJ IDEA and Gradle - Cannot be applied to '(groovy.lang.Closure)'

I have a Gradle file which, whenever I load open it in IntelliJ IDEA 14.1.5, shows IDE errors for the entire file. Namely all the errors seem to be either:

java.lang.String errors

java.lang.String errors


groovy.lang.Closure errors

groovy.lang.Closure errors

I've tried clearing the file's contents and only writing the top line:

group ''

but even that results in an error.

For context's sake - this is an individual module in a larger SpringBoot project. This module is a set of simple static files (with Gradle for CSS compilation, static analysis, etc), while the rest are Java modules, and are not having Gradle issues.

Can anyone think why IntelliJ would be struggling to understand this Gradle file?

Answer Source

For anyone looking for a similar fix, this boiled down to the type of the module. My module was defined in my .iml file as


I created a new Gradle module and pasted in the same contents, deleted the original, renamed the new module to have the same name as the old one, and everything worked fine. When I diffed the results the only change was that the .iml file now said:


So there's the answer, seemingly. Change your module from "web" to "java".