Fred Bricon [
https://community.jboss.org/people/fbricon] modified the blog post:
"Annotation Processing support in m2e"
To view the blog post, visit:
https://community.jboss.org/community/tools/blog/2012/05/20/annotation-pr...
--------------------------------------------------------------
Maven Integration for Eclipse JDT Annotation Processor Toolkit a.k.a *m2e-apt* is now
available in its version 1.0. m2e-apt aims at providing automatic Annotation Processing
configuration in Eclipse based on your project's pom.xml and its classpath
dependencies (Requires Java >= 1.6).
m2e-apt supports both annotation processing set on the
http://maven.apache.org/plugins/maven-compiler-plugin/index.html maven-compiler-plugin or
the
http://code.google.com/p/maven-annotation-plugin/ maven-processor-plugin (the latter
takes precedence over the former).
For example, to enable the JPA modelgen annotation processor, you can either set :
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.4</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
<dependencies>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-jpamodelgen</artifactId>
<version>1.2.0.Final</version>
</dependency>
</dependencies>
</plugin>
or
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.4</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<compilerArgument>-proc:none</compilerArgument>
</configuration>
</plugin>
<plugin>
<groupId>org.bsc.maven</groupId>
<artifactId>maven-processor-plugin</artifactId>
<version>2.0.5</version>
<executions>
<execution>
<id>process</id>
<goals>
<goal>process</goal>
</goals>
<phase>generate-sources</phase>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-jpamodelgen</artifactId>
<version>1.2.0.Final</version>
</dependency>
</dependencies>
</plugin>
The generated source folders (target/generated-sources/annotation for
maven-compiler-plugin; target/generated-sources/apt for maven-processor-plugin) are
automatically added to the project classpath.
https://community.jboss.org/servlet/JiveServlet/showImage/38-4947-18598/m...
https://community.jboss.org/servlet/JiveServlet/downloadImage/38-4947-185...
By default, Annotation Processing is managed by Eclipse JDT APT, so a change in your
source classes triggers incremental processing automatically. The downside of using JDT
APT is, there's no separation between main and test classes (the way
maven-processor-plugin handles them).
To mitigate that limitation, you can change the workspace or project preferences to
delegate annotation processing to maven, instead of JDT APT. This will result in slower
incremental builds (all classes will be processed) but will provide identical results to
maven command line builds. Note this only works when using maven-processor-plugin. When
annotation processing is driven by maven-compiler-plugin, JDT APT is always used in
eclipse.
Automatic annotation processing configuration from the maven pom.xml can also be disabled
altogether. In this case, your manual settings for Eclipse JDT APT will remain untouched.
Go to Window > Preferences > Maven > Annotation processing or right-click on your
project > Properties > Maven > Annotation processing to select the Annotation
Processing strategy of your choice.
https://community.jboss.org/servlet/JiveServlet/showImage/38-4947-18599/m...
https://community.jboss.org/servlet/JiveServlet/downloadImage/38-4947-185...
m2e-apt is heavily based on the work from two community members :
* a
https://bugs.eclipse.org/bugs/show_bug.cgi?id=335036 patch for m2e by Karl M. Davis,
from Knowledge Computing Corp, implementing Eclipse JDT APT configuration based on the
maven-compiler-plugin's configuration.
*
https://github.com/excilys/m2e-extras/tree/master/com.excilys.ebi.m2e.apt
com.excilys.ebi.m2e.apt by Stéphane Landelle, from eBusiness Information, Excilys Group,
implementing direct maven-processor-plugin invocation from m2e.
m2e-apt is available :
* via a stable update site
http://download.jboss.org/jbosstools/updates/m2e-extensions/m2e-apt
http://download.jboss.org/jbosstools/updates/m2e-extensions/m2e-apt
* for JBoss Tools 3.0.0.Beta3 users, via the Software/Update tab in JBoss Central
* bundled with
https://devstudio.jboss.com/earlyaccess/ JBoss Developer Studio
5.0.0.Beta3
Source code is available at
https://github.com/jbosstools/m2e-apt github. If you find any
bug, please raise a ticket on m2e-apt's
https://github.com/jbosstools/m2e-apt/issues?state=open issue tracker.
Happy hacking,
Fred
https://twitter.com/#!/fbricon https://twitter.com/#!/fbricon
--------------------------------------------------------------
Comment by going to Community
[
https://community.jboss.org/community/tools/blog/2012/05/20/annotation-pr...]