Bug 533480 - m2e-apt processes test resources in a Maven project
Summary: m2e-apt processes test resources in a Maven project
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: APT (show other bugs)
Version: 4.7.1a   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Generic inbox for the JDT-APT component CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2018-04-11 18:52 EDT by Aritz Bastida CLA
Modified: 2022-07-26 13:58 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Aritz Bastida CLA 2018-04-11 18:52:13 EDT
I just tried out the following APT processor:

    <dependency>
       <groupId>org.springframework</groupId>
       <artifactId>spring-context-indexer</artifactId>
       <optional>true</optional>
    </dependency>

I configured it as a dependency in maven-compiler-plugin, and works fine in Maven. In Eclipse, I'm using JDT APT option; which apparently works fine too... except that, not only it processes the "src/main" folder, but also "src/test". 

As a consequence, the APT processor generates test data in the index file, which breaks my applications.

Is there any way to disable APT processor in the "test-compile" phase? i tried to configure compiler's implied executions (default-compile and default-testCompile) differently, so as to disable annotation processors in the test phase, but with no luck.

Is it a bug in m2e-apt?

Thank you!
Aritz
Comment 1 Till Brychcy CLA 2018-04-12 02:15:20 EDT
In eclipse 4.8 M6, support for annotations processing of test sources has been added (see https://www.eclipse.org/eclipse/news/4.8/M6/#JDT).
Running specific annotations processors for test sources cannot be suppressed, but the generated files are  put into a separate output folder, maybe this will solve your use case?
(Note you'll need the updated m2e and m2e-apt versions that configure this)
Comment 2 Aritz Bastida CLA 2018-04-12 05:05:01 EDT
T(In reply to Till Brychcy from comment #1)
> In eclipse 4.8 M6, support for annotations processing of test sources has
> been added (see https://www.eclipse.org/eclipse/news/4.8/M6/#JDT).

Thank you for your quick response, Till. Will this feature be backported to Eclipse 4.7.1 (or at least, to 4.7.x branch)?
Comment 3 Till Brychcy CLA 2018-04-12 06:24:13 EDT
(In reply to Aritz Bastida from comment #2)
> Thank you for your quick response, Till. Will this feature be backported to
> Eclipse 4.7.1 (or at least, to 4.7.x branch)?

No.
Comment 4 Aritz Bastida CLA 2018-04-12 06:33:05 EDT
mmmm ok
Comment 5 Vsevolod Golovanov CLA 2018-08-14 08:25:03 EDT
We have the same problem. We don't have annotation processing for test sources in a Maven (command line) build, therefore we don't want it in Eclipse too. Could JDT provide an option to disable test source processing?
Comment 6 Eclipse Genie CLA 2022-07-26 13:58:36 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.