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 208286

Summary: target/generated-sources/test-annotations mishandled
Product: projects Reporter: JIa6upuHT
Component: MavenAssignee: Jesse Glick <jglick>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P3    
Version: 7.1   
Hardware: All   
OS: All   
Issue Type: DEFECT Exception Reporter:
Bug Depends on:    
Bug Blocks: 187648    
Attachments: screenshot + project source

Description JIa6upuHT 2012-02-11 11:28:43 UTC
Created attachment 115618 [details]
screenshot + project source
Comment 1 Jesse Glick 2012-02-14 19:32:01 UTC
See MavenAnnotationProcessingQueryImplTest; there is no distinction made yet between test and main annotation sources.

Also there is a bug in maven-compiler-plugin, it seems. It should be creating target/generated-test-sources/annotations yet it is creating target/generated-sources/test-annotations instead. This means that TestTargetImpl.java is put in the same sourcepath as Target.java, which is of course wrong and probably responsible for the error in the Java editor. Needs to filed and fixed upstream; as a workaround, NbMavenProjectImpl.getGeneratedSourceRoots could hardcode support for this particular dir name.
Comment 2 Jesse Glick 2012-02-15 19:42:11 UTC
Reporter adds a workaround: add to maven-compiler-plugin configuration

<generatedTestSourcesDirectory>${project.build.directory}/generated-test-sources/annotations</generatedTestSourcesDirectory>

which is what the testCompile mojo's default ought to be.
Comment 3 Jesse Glick 2012-02-15 20:50:22 UTC
Reporter writes (please use BZ's Comments field in the future):

----
when use only generatedTestSourcesDirectory that produce error on
generated files by annotation (non test)
on this need use  generatedTestSourcesDirectory and generatedSourcesDirectory
<goal> to-use is not necessary
----

but should check again - I tried adding just <generatedTestSourcesDirectory>${project.build.directory}/generated-test-sources/annotations</generatedTestSourcesDirectory> to the sample project/pom.xml, and doing a clean build, and all files looked fine including TargetImpl.java.

By the way it should also work to refer to generated sources from static sources, e.g.:

public abstract class Target {
    static final Target t = new TargetImpl();
}

or

abstract class TestTarget {
    static final TestTarget t = new TestTargetImpl();
}

even on a clean project.
Comment 4 Jesse Glick 2012-04-02 22:57:45 UTC
Filed https://jira.codehaus.org/browse/MCOMPILER-167 for plugin issue.
Comment 5 Jesse Glick 2012-04-03 19:11:07 UTC
core-main #e928fc875ffd
Comment 6 Quality Engineering 2012-04-04 10:11:11 UTC
Integrated into 'main-golden', will be available in build *201204040400* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/0fbbbec19dbe
User: Jesse Glick <jglick@netbeans.org>
Log: (mentioned in #208286) MCOMPILER-167 workaround: treat target/generated-sources/test-*/ as a mistaken synonym for target/generated-test-sources/*/.
Comment 7 Jesse Glick 2012-05-01 21:59:54 UTC
(In reply to comment #4)
> Filed https://jira.codehaus.org/browse/MCOMPILER-167 for plugin issue.

Fixed in 2.4.