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 184372 - Error building Maven-based APISupport project with tests
Summary: Error building Maven-based APISupport project with tests
Status: RESOLVED WORKSFORME
Alias: None
Product: apisupport
Classification: Unclassified
Component: Maven (show other bugs)
Version: 6.x
Hardware: All All
: P3 normal (vote)
Assignee: Jesse Glick
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-04-16 15:46 UTC by Petr Jiricka
Modified: 2010-11-16 21:06 UTC (History)
4 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Petr Jiricka 2010-04-16 15:46:39 UTC
1. Create a Maven-based NBM project
2. Create an Options panel through the wizard
3. Build the project
4. Generate JUnit tests for the options panel class
5. Build the project again (or run mvn test from the command line)

I got the following build error:
....
[INFO] [compiler:testCompile {execution: default-testCompile}]
[WARNING] File encoding has not been set, using platform encoding MacRoman, i.e. build is platform dependent!
[INFO] Compiling 1 source file to /Users/petrjiricka/NetBeansProjects/mavenproject62/target/test-classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] error: Exception thrown while constructing Processor object: org/openide/filesystems/annotations/LayerGeneratingProcessor
[INFO] 1error
....
Comment 1 Petr Jiricka 2010-04-19 08:39:30 UTC
The workaround is to declare the maven-compiler-plugin as follows:

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.2</version>
                <executions>
                    <execution>
                        <id>default-compile</id>
                        <configuration>
                            <source>1.6</source>
                            <target>1.6</target>
                        </configuration>
                    </execution>
                    <execution>
                        <id>default-testCompile</id>
                        <configuration>
                            <compilerArgument>-proc:none</compilerArgument>
                            <source>1.6</source>
                            <target>1.6</target>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

But this is still not 100% correct, because what if the test sources do contain some
other processor that you *do* want to run?
Comment 2 Petr Jiricka 2010-04-19 12:08:49 UTC
Just discussed this with Dafe - Jesse is probably a better person to look into this and suggest how to fix:
- Make changes to our processor?
- Change how we generate the pom for NBM-Maven projects?
- Ask the maven-compiler-plugin maintainers to make some changes on their side and release a new version?
- ... ?
Comment 3 Jesse Glick 2010-04-19 16:41:05 UTC
(In reply to comment #2)
> Ask the maven-compiler-plugin maintainers to make some changes on their side
> and release a new version?

Probably. The -processorpath needs to include the *transitive* dependencies of the module. Compare how the NB Ant build harness uses ${module.run.classpath} for the processor path.
Comment 4 Antonin Nebuzelsky 2010-05-10 15:31:03 UTC
How about introducing what Petr listed as a workaround into the project archetype in 6.9 as the quick fix?

<id>default-testCompile</id>
  <configuration>
    <compilerArgument>-proc:none</compilerArgument>
...

It would only limit hypothetical user's usage of annotation processors in tests, right? Not a usecase we would take as a priority I guess. Would people agree?
Comment 5 Jesse Glick 2010-05-10 17:27:21 UTC
(In reply to comment #4)
> It would only limit hypothetical user's usage of annotation processors in
> tests, right?

Yes.

> Not a usecase we would take as a priority I guess. Would people
> agree?

Don't know; we use APs in tests fairly frequently, though as not as much as in primary source roots.

What makes it work for primary source roots? That fix should be extended to test source roots.
Comment 6 Antonin Nebuzelsky 2010-05-11 12:41:18 UTC
> What makes it work for primary source roots?
> That fix should be extended to test source roots.

Neither I nor Dafe are too familiar with the solution.

Milosi, could you please help us by pointing to the right place or how extending the existing solution could start working also for test source roots?
Comment 7 Milos Kleint 2010-05-11 12:54:01 UTC
it's not clear to me why the test compilation fails. what is missing from CP and why?

there's one thing in the way we generate the repository content for nb.org artifacts that could be related. We for artifacts in org.netbeans.api group (those having api packages) we only generate dependencies to other public packages artifacts and omit dependencies into the org.netbeans.modules groupid space. Not entirely correct in terms of maven dependency mechanism, but allow to work with most api dependencies without downloading the internet and having teh internet on the classpath and completion..
Comment 8 David Simonek 2010-05-18 12:04:45 UTC
Further observations:
- bug does exist only for SNAPSHOT nbm artifacts, beta and FCS will be OK, so I'm downgrading to P3

- here is stack trace (run with mvn --errors):
Trace
org.apache.maven.BuildFailureException: Compilation failure
error: Exception thrown while constructing Processor object: org/openide/filesystems/annotations/LayerGeneratingProcessor

        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:715)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:556)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:535)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
        at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
        at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
        at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
        at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: org.apache.maven.plugin.CompilationFailureException: Compilation failure
error: Exception thrown while constructing Processor object: org/openide/filesystems/annotations/LayerGeneratingProcessor

        at org.apache.maven.plugin.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:656)
        at org.apache.maven.plugin.TestCompilerMojo.execute(TestCompilerMojo.java:160)
        at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
        ... 17 more
Comment 9 David Simonek 2010-05-18 12:39:36 UTC
I noticed there are some strange messages about failing downloads when using SNAPSHOT versions. Hmm, but I doubt that could cause exceptions...
--------
Downloading: http://bits.netbeans.org/maven2/org/netbeans/api/org-openide-util/20100514.063437-1/org-openide-util-20100514.063437-1.pom
Unable to find resource 'org.netbeans.api:org-openide-util:pom:20100514.063437-1' in repository netbeans (http://bits.netbeans.org/maven2)
Downloading: http://repo1.maven.org/maven2/org/netbeans/api/org-openide-util/20100514.063437-1/org-openide-util-20100514.063437-1.pom
Unable to find resource 'org.netbeans.api:org-openide-util:pom:20100514.063437-1' in repository central (http://repo1.maven.org/maven2)
---------
Sure such artifacts are not there, they are in snapshot repo, but why is Maven trying even when I specify that shapshots can't be in such repos...?
Comment 10 Jesse Glick 2010-11-16 21:06:42 UTC
Could not reproduce in a dev build, using SNAPSHOT platform deps.

http://jira.codehaus.org/browse/MNBMODULE-100 might have fixed whatever was wrong, but not sure.