Search code examples
groovyintellij-ideagradlejava-package

Problems with java package names in Gradle build with IntelliJ IDEA


I have a Gradle project and in it I have groovy and java classes at the same package. The build works fine but when I import the project in InteliJ 13 the IDE tells me that only in the java files I have wrong package names.

\src\main\groovy\com\example\boo\foo\Problem.java

with package

package com.example.boo.foo;

And there is no error with

\src\main\groovy\com\example\boo\foo\Sample.groovy

with package

package com.example.boo.foo

How to remove this error?


Solution

  • You need to make sure you Java code is packaged under java and your groovy code is packaged under groovy. See example in the screenshot below:

    enter image description here