Project
IntelliJ IDEA
Priority
Normal
Type
Bug
Fix versions
No Fix versions
State
Fixed
Assignee
Anton Makeev
Subsystem
Maven Integration
Affected versions
No Affected versions
Fixed in build
108.65  
  • Created by   M. Erik Husby
    3 years ago (15 Aug 2008 19:36)
  • Updated by   Venkat Sonnathi
    18 months ago (14 Jul 2010 14:31)
  • Jira: IDEADEV-31529
    (history, comments)
 
IDEA-45212 Directories under target/generated-sources incorrectly added to source paths
5
Issue is visible to: All Users
  The issue is visible to the selected user group only
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
Comments (7)
 
History
 
Linked Issues (?)
 
Paul Smith
  Paul Smith
04 Sep 2008 21:21
3 years ago
I have a similar but different problem. I'm generating source under target/generated-source but Intellij is picking up the source path as including the first part of the package.

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
Keith GAnger
  Keith GAnger
26 Sep 2008 22:14
3 years ago
I also have a similar issue.

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.
Anton Makeev
  Anton Makeev
21 Oct 2008 17:30
3 years ago
Paul,

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.
Anton Makeev
  Anton Makeev
21 Oct 2008 17:32
3 years ago
If IDEA discovers the groovy plugin attached to the pom, it won't add 'generated-sources/groovy-stubs/...' as source folders.
Anton Makeev
  Anton Makeev
22 Oct 2008 17:45
3 years ago
The fix will be available right after 8.0 since it requires some critical rework.
Danny Siu
  Danny Siu
10 Nov 2008 10:16
3 years ago
Is there any work around for this problem?
KappaYeates
  KappaYeates
22 Dec 2008 12:45
3 years ago
this bug still exists at eap 9572.