maven-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tibor Adam Varga (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (MCOMPILER-240) Generated sources directory should not be added to compiler's source roots
Date Fri, 05 Feb 2016 12:20:39 GMT

    [ https://issues.apache.org/jira/browse/MCOMPILER-240?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15134077#comment-15134077
] 

Tibor Adam Varga commented on MCOMPILER-240:
--------------------------------------------

With regard to executing annotation processors, the Maven Compiler Plugin *is broken* and
has been broken since version 3.2.

If you are to use a newer version of the plugin, you are forced to either do a *full build*
at all times rather than incremental builds, or *misuse* the Annotation Processor API to generate
source files as _resources_ rather than sources that they actually are. One adds up to wasted
time and resources, the other is just plain wrong.

I have diligently researched and described the problem, pinpointed the exact cause of it,
and provided a test case and a patch.

That has been over a year ago yet no one cared to take a look at this issue since. It may
have taken longer to compose this comment than what it would probably take to apply the provided
patch.

What else should one do to get their voice heard and their problem responded to?

> Generated sources directory should not be added to compiler's source roots
> --------------------------------------------------------------------------
>
>                 Key: MCOMPILER-240
>                 URL: https://issues.apache.org/jira/browse/MCOMPILER-240
>             Project: Maven Compiler Plugin
>          Issue Type: Bug
>    Affects Versions: 3.2, 3.3, 3.5
>         Environment: Apache Maven 3.2.5 (12a6b3acb947671f09b81f49094c53f426d8cea1; 2014-12-14T18:29:23+01:00)
> Java(TM) SE Runtime Environment (build 1.6.0_65-b14-462-11M4609)
> Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-462, mixed mode)
> Java(TM) SE Runtime Environment (build 1.7.0_45-b18)
> Java HotSpot(TM) 64-Bit Server VM (build 24.45-b08, mixed mode)
> Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
> Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)
>            Reporter: Tibor Adam Varga
>         Attachments: Generated_sources_directory_added_to_source_roots_after_compilation.patch,
code-generation-test-case.tar.bz2
>
>
> I am using annotation processors with Maven and I keep getting errors when compiling
with generated sources already present from a previous run.
> I have modified one of the test cases submitted for [MCOMPILER-157|http://jira.codehaus.org/browse/MCOMPILER-157]
to induce the error by generating a source file _as source file_ rather than as a resource.
Untar the test case and run {{mvn clean test -q && mvn test -q}} to verify.
> What I found is that {{AbstractCompilerMojo}} in version 3.2 of the compiler plugin adds
the generated sources directory to the compiler's source root list, and that has two undesirable
effects:
> # Sources generated in the previous run will be stale the next time around and cause
recompilation.
> # The compiler will consider the previously generated source files to be initial inputs.
> The first one is mostly harmless but the second one is deadly, as it breaks the processing
environment of the annotation processors.
> From the {{javax.annotation.Filer}} documentation in JDK 8:
> bq. "During each run of an annotation processing tool, a file with a given pathname may
be created only once. Any subsequent attempt to create the same file during a run will throw
a FilerException [...] The initial inputs to the tool are considered to be created by the
zeroth round; therefore, attempting to create a source or class file corresponding to one
of those inputs will result in a FilerException."
> Thus by adding the generated sources directory to the compiler's source roots, the compiler
plugin causes annotation processors to inadvertently break their contract with the compiler.
> I get the expected behavior when lines 511-540 in {{AbstractCompilerMojo}} are moved
after the compiler invocation, say to line 806. See the attached patch.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message