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.
Environment: Mac OS X 10.5.4, Java 1.5
Issue was resolved
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
I am using 8.0 M1
The maven importer is constantly adding the target/generated-source to my Source Folders.
I also have src/main/groovy as a source folder. Therefore when I build with with maven the .java sources are generated and added as source.
I then get Errors with my groovy sources saying that the class name already exists.
It would be ideal to be able to tell the maven importer to not use the generated-sources directory at all.
The general contract for the 'generated-sources' folder is that it contains sub-folders for each plugin; IDEA looks into each sub-folder and adds its content as 'source folder'.
Therefore, if you want IDEA to correctly configure your generated sources, please edit your scripts so that sources are placed under 'generated-sources/<some-folder>' directory.
Thanks,
Anton Makeev.