This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 207107 - IDE editor should recognize generated sources in maven project.
Summary: IDE editor should recognize generated sources in maven project.
Status: CLOSED FIXED
Alias: None
Product: projects
Classification: Unclassified
Component: Maven (show other bugs)
Version: 7.1
Hardware: Macintosh (x86) Mac OS X
: P3 normal (vote)
Assignee: Jesse Glick
URL:
Keywords:
: 209799 (view as bug list)
Depends on:
Blocks: 187648
  Show dependency tree
 
Reported: 2012-01-10 08:58 UTC by t_yano
Modified: 2012-07-17 15:10 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
sample projects for reproducting this issue (11.17 KB, application/zip)
2012-01-10 08:58 UTC, t_yano
Details

Note You need to log in before you can comment on or make changes to this bug.
Description t_yano 2012-01-10 08:58:03 UTC
Created attachment 114753 [details]
sample projects for reproducting this issue

When I use annotation processor for generating source code with maven project, and some (not generated, normal) classes use the generated classes, maven compile correctly the sources which use generated classes, but IDE editor displays the sources with error markers.

And IDE doesn't show any suggestions on auto-completion though the classes are already generated and IDE displays the classes in 'project' tab.

This issues does not occur on NB's default Ant project. In Ant project, IDE recognizes generated classes correctly and displays auto-completion correctly.

I attached 2 maven-projects for showing this issue.

1. unpack the attached zip file. 
2. do 'mvn install' on 'sampleprocessor' project, which contains a sample AnnotationProcessor for generating code.
3. do 'mvn install' on 'generatingissue' project.

On the 3rd action, you will see the compilation finish correctly (maven will show some warning in 'generating-source' phase, but compilation will finish without errors, because necessary classes is generated in the 'generating-source' phase).

Maven can compile the project correctly, but NetBeans shows some error markers on IDE Editor.
Comment 1 Jesse Glick 2012-01-11 20:35:35 UTC
NB does not currently read <annotationProcessors> from maven-compiler-plugin configuration. For now it just runs all annotation processors registered in the normal way: in META-INF/services/javax.annotation.processing.Processor.

BTW the sample project does not work from mvn clean compile for me in JDK 7u2:

[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ generatingissue ---
[INFO] Compiling 2 source files to /tmp/netbeans-generation-issue/generatingissue/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] /tmp/netbeans-generation-issue/generatingissue/src/main/java/jp/javelindev/netbeans/generatingissue/ClassWithIssue.java:[4,0] error: package jp.javelindev.netbeans.generatingissue.impl does not exist
[ERROR] /tmp/netbeans-generation-issue/generatingissue/src/main/java/jp/javelindev/netbeans/generatingissue/ClassWithIssue.java:[15,32] error: cannot find symbol
[INFO] 2 errors 
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE

Not sure why. (I will try to file a bug for javac.) It does work in JDK 6, in which case "Generated Sources (annotations)" appears in the Projects tab, but the Java scanner will still ignore this root since it is expecting to use 269-generated sources just from the internal compiler.
Comment 2 Jesse Glick 2012-01-11 21:07:13 UTC
(In reply to comment #1)
> Not sure why. (I will try to file a bug for javac.)

Filed. The workaround is to explicitly

import jp.javelindev.netbeans.generatingissue.impl.GenerateOriginImpl;

from ClassWithIssue.java rather than using a wildcard. This does not have much to do with the IDE problem, just mentioning in case you want your code to be buildable using JDK 7 before a fix is released.
Comment 3 Jesse Glick 2012-01-11 21:28:17 UTC
core-main #cc33ca867115
Comment 4 Quality Engineering 2012-01-13 21:52:25 UTC
Integrated into 'main-golden'
Changeset: http://hg.netbeans.org/main-golden/rev/cc33ca867115
User: Jesse Glick <jglick@netbeans.org>
Log: #207107: IDE editor should recognize generated sources in maven project.
Comment 5 t_yano 2012-01-16 05:14:52 UTC
I tried a nightly build yesterday, but one related issue remains.
If you build the 'generatingissue' project in the following order, you'll see an error marker on the file icon of 'ClassWithIssue.java' in 'Project' tab.

IDE editor is fine. It is displayed without any error marker, but the icon in 'Project' tab remains as a error file.

1. use JDK6 for build.
2. use a wildcard for import in ClassWithIssue.java:

import jp.javelindev.netbeans.generatingissue.impl.*;

3. clean the project at first.

  The project will be displayed as it have some errors, because necessary-sources is not generated yet.

4. build the project 'generating issue'

  an error marker on a file icon still remains.


Strangely, if you don't use a wildcard-import on ClassWithIssue.java, All error markers go away without any build (even if you clean the project, no error markers appear).
Comment 6 Jesse Glick 2012-01-17 23:18:42 UTC
Error badges are a separate matter; what you observed should be filed separately in java/source blocking bug #121950 (but might be a duplicate of bug #190852).
Comment 7 Jesse Glick 2012-03-27 20:35:23 UTC
*** Bug 209799 has been marked as a duplicate of this bug. ***