“Class already exists” error on Groovy class, repeatedly rewriting module settings from mvn pom

Answered

I can't work out how to permanently get rid of the "class already exists" error in the groovy editor on my groovy class declaration.

I have a multi-module project with many Java projects, and this one maven plugin project with a groovy class.

When I go into the module settings and remove the "target/generated-sources" from the Sources settings, IntelliJ will be happy for a while.

Then at some point, probably after editing the pom, IntelliJ resets the settings and I saw a message saying it's read them all from the pom.

How can I either configure IntelliJ just to stick with my version of the module settings, or how can I configure the maven pom to make the IntelliJ module settings ignore the generated-sources so I don't get that error?

Or is there a different approach? I seriously doubt I have found a bug (in 2018.1.6) but I can't find any solution on the rest of the web.

0
4 comments
0
Avatar
Permanently deleted user

Yes, temporarily, but then IntelliJ and Maven will collaborate to break it again when I next edit the pom. This is what happens in the module settings - my original one where I removed the generated-sources dir is backed-up or something similar to "gem-groovy-maven-plugin(1)", to make way for a new one which doesn't seem happy - I've just noticed today that it says it's still loading the gem-groovy-maven-plugin:

0

In case of maven project, you should exclude it in pom.xml using <exclude> tag.

0
Avatar
Permanently deleted user

Well, I have added an excludes element to the maven-compiler-plugin configuration, assuming that is what you meant. I now have this (using polyglott yaml):

build:
plugins:
- artifactId: maven-compiler-plugin
groupId: org.apache.maven.plugins
version: 3.6.1
configuration:
source: ${maven.compiler.version}
target: ${maven.compiler.version}
compilerArgument: -parameters
debug: true
debuglevel: lines,vars,source
includes: [ ${project.basedir}/src/main/groovy/**/* ]
excludes: [ ${project.build.directory}/generated-sources/**/* ]

It seems to be happy now. Thanks.
0

Please sign in to leave a comment.