问题描述
我有一个Gradle文件,每当我在IntelliJ IDEA 14.1.5中打开它时,它显示整个文件的IDE错误。即所有的错误似乎都是:
java.lang.String错误
或
常规.lang.Closure错误
group'com.me.blah'
但即使这样也会导致错误。
为了上下文的缘故 - 这是一个更大的SpringBoot项目中的独立模块。这个模块是一组简单的静态文件(使用Gradle for CSS编译,静态分析等),其余的都是Java模块,并且 没有Gradle问题。
任何人都能想到为什么IntelliJ会努力去理解这个Gradle文件吗?
对于类似的修复,这可以归结为模块的类型。我的模块在我的.iml文件中定义为: type =WEB_MODULE
我创建了一个新的Gradle模块并粘贴了相同的内容,删除了原始模块,将其重命名为与旧模块名称相同的新模块,一切正常。当我分析结果时,唯一的变化是.iml文件现在说:
type =JAVA_MODULE
看起来有个答案。将模块从web更改为java。
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
or
groovy.lang.Closure errors
I've tried clearing the file's contents and only writing the top line:
group 'com.me.blah'
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?
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
type="WEB_MODULE"
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:
type="JAVA_MODULE"
So there's the answer, seemingly. Change your module from "web" to "java".
这篇关于IntelliJ IDEA和Gradle - 无法应用于'(groovy.lang.Closure)'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!