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 - target/generated-sources/test-annotations mishandled
Summary: target/generated-sources/test-annotations mishandled
Status: RESOLVED FIXED
Alias: None
Product: projects
Classification: Unclassified
Component: Maven (show other bugs)
Version: 7.1
Hardware: All All
: P3 normal (vote)
Assignee: Jesse Glick
URL:
Keywords:
Depends on:
Blocks: 187648
  Show dependency tree
 
Reported: 2012-02-11 11:28 UTC by JIa6upuHT
Modified: 2012-05-01 21:59 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
screenshot + project source (124.08 KB, application/zip)
2012-02-11 11:28 UTC, JIa6upuHT
Details

Note You need to log in before you can comment on or make changes to this bug.
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.