Our projects can generate sources from multiple sources and for multiple reasons. So our target/generated-sources will have multiple sub-directories. Intellij adds these directories without regard to the correct package structure. And if one has auto import turned on a for a Maven based project, the paths are always updated even if one has manually corrected them.
One example is using the GMaven groovy based plugin. This plugin generates Java stubs for Groovy sources. The Java stubs end up in one of two directories, target/generated-sources/groovy-stubs/main or target/generated-sources/groovy-stubs/test.
There are two side effects of adding the paths incorrectly.
1. Because the paths do not match the package structure, Intellij will constantly recompile them.
2. And when the test directory ends up in the main src path, one can get compilation errors.
So I'm generating 'target/generated-source/com/foo/bar/MyClass.java' and Intellij is adding 'target/generated-source/com' as the source path. This obviously then fails to compile as the package name doesn't match the directory.
I can temporarily fix the issue by changing the source path in my project settings, but this get's reverted back to the above broken path everytime Intellij re-syncs with Maven.
Paul