in IntelliJ (2016.2 and previous) we have our Groovy classes marked red with the error "class already exists". I think we can exclude that the cause is the stub-generation, as this is deactivated.
Probably it's caused in our constellation: We have included our compiled groovy (and java) classes in a jar that is registered as dependency.
Dependency MyProduct.jar contains com.mycompany.MyGroovyClass
Our source contains com.mycompany.MyGroovyClass
The error disappears if the dependency is registered with Test-Scope, in all other scopes the error appears.
However, in our structure we kinda have to include the compiled classes in a compile scope, as we want to avoid that each developer needs to compile all classes (I know about the compile in background ability, but we have a constellation that prevents this from working).
We have no errors in com.mycompany.MyJavaClass
which exists as well in source and in MyProduct.jar.
Any ideas on how we can solve this?
We've been suffering the same issue, it seems to be that IntelliJ registers the Java class, but also the Groovy class, and because of that it is showing that message (BTW, we are using a Maven Project).
So we ended up by going to the target folder -> right click -> Mark Directory As -> Excluded. Then, this setting will be saved on the IML file, and it won't happen again.
Hope it works for your as well! Cheers
I'm using gmavenplus-plugin:1.5
After marking target/generated-sources/generated-sources/main
as "Excluded", The error disappeared. I even did "invalidate cache and restart", It persists the setting. This is great. Intellij 2017.1.5
We have two ways to fix this issue
target folder -> generated-sources -> groovy-stubs -> Right click main folder -> Mark Directory As -> Excluded
Remove <goal>generateStubs</goal>
from gmavenplus plugin
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With