Skip to content
This repository has been archived by the owner on Feb 18, 2022. It is now read-only.

annotation processing not working with JDT / maven-compiler-plugin #22

Open
vguna opened this issue Jul 8, 2013 · 4 comments
Open

annotation processing not working with JDT / maven-compiler-plugin #22

vguna opened this issue Jul 8, 2013 · 4 comments

Comments

@vguna
Copy link

vguna commented Jul 8, 2013

Hi.

I'm using Juno Service Release 2 with JBoss Tools 1.4.0 Final and Maven Integration for Eclipse JDT APT 1.0.1.201209200721 under JDK7 64bit on Windows 7.

I have a multimodule maven build with my own annotation processors defined in two separate modules. Everything is working fine with plain maven build on cmdline and necessary files get generated by the processors under target/generated-sources/annotations as expected on the projects using my custom annotations.

Now I'm using the m2e-apt as described here:

https://community.jboss.org/en/tools/blog/2012/05/20/annotation-processing-support-in-m2e-or-m2e-apt-100-is-out

I'm using the recommended option with the maven-compiler-plugin. Updating maven project configuration and refreshing/rebuilding everything doesn't work for me. No additional target folder "target/generated-sources/annotations" is created and/or added to the eclipse project - even after refreshing. I also added direct dependencies to the annotation processor factories to the pom.xml as described here:

#14 (comment)

Either as "normal" deps and/or plugin deps doesn't do the trick. My annotation processor factories are providing the META-INF/services/javax.annotation.processing.Processor files.

As an alternative I used the 2nd (experimental) maven-processor-plugin option. This seems to work better. The apt folder is added to the eclipse project and files are created as expected. But there is another problem using this option:

Right after saving a file, processing starts and JBoss Tools are publishing the changes to my running JBoss server. But this fails with the "workspace is out of sync..." message refering to the generated files. Seems clear to me, since these files were created/updated outside of eclipse calling maven. Also using the "refresh workspace" option from eclipse preferences doesn't work for me. Maybe the plugin doesn't trigger and automatic workspace refresh after maven has finished its job?!

So neither option one or two works for me. Any hints why the preferred option one using maven-compiler-plugin doesn't work for me?

Thanks.

@fbricon
Copy link
Member

fbricon commented Jul 10, 2013

When using maven-compiler-plugin for AP, the processing is always delegated to JDT APT in eclipse, so incremental build can be supported. However, JDT APT doesn't support annotation processors from opened workspace projects (see issue #15).

As for the out-of-sync issue, please provide a small sample project reproducing the issue (from a github repo for instance)

@fjakop
Copy link

fjakop commented Aug 6, 2013

I have the same problem, my processor does nor seem to be called. I installed the processor via "mvn install" and closed the project. I configured the dependency in the maven-compiler-plugin

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <configuration>
        <source>1.6</source>
        <target>1.6</target>
    </configuration>
    <dependencies>
        <dependency>
            <groupId>xxx.annotations</groupId>
            <artifactId>annotations-processor</artifactId>
            <version>1.0.0-SNAPSHOT</version>
        </dependency>
    </dependencies>
</plugin>

and activated delegating to JDT in eclipse.
My processor simply does getProcessingEnvironment().getMessager().printMessage(Kind.ERROR, "this is a test");
for testing purposes.
The file META-INF\services\javax.annotation.processing.Processor is present in my processor-jar and contains the processor class.

When I let eclipse build my project I do not see any processor-related output in the maven console nor an error marker in the project's problems view, as I would expect.

Can you give me a hint what's awry here?

P.S.: Using the processor plugin works, but produces no feasible error marker, just Error executing (org.bsc.maven:maven-processor-plugin:2.2.4:process:process:generate-sources)

@dnouls
Copy link

dnouls commented Jan 20, 2017

I am facing the same issue. Whatever I tried this plugin never triggers my custom APT.

At the same time, I have to explicitly state what APT classes that needs to be executed by maven-compiler-plugin because otherwise maven does not pick it up either. I created a CR on the latest maven-compiler-plugin as well since that has been broken since older versions.

@mickaelistria
Copy link

m2e-apt's code is now included in https://github.com/eclipse-m2e/m2e-core , please consider reporting issue to https://github.com/eclipse-m2e/m2e-core/issues if it's still relevant.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants