I've got this working by doing as Max mentioned and manually add the JPA facet to the project after getting m2e to generate your project files, then commit the eclipse .settings file.
There's other things to be aware of. You need eclipse and maven to generate the metamodel sources in the same directory or else you'll get compile errors. Here's a fragment from my pom.xml where I configure the metamodel generation, including the folder where the source files are generated...
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<compilerArgument>-proc:none</compilerArgument>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>src/main/jpa-metamodel-generated</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.bsc.maven</groupId>
<artifactId>maven-processor-plugin</artifactId>
<version>2.0.4</version>
<executions>
<execution>
<id>process</id>
<goals>
<goal>process</goal>
</goals>
<phase>generate-sources</phase>
<configuration>
<compilerArguments>-Aopenjpa.metamodel=true</compilerArguments>
<processors>
<processor>org.apache.openjpa.persistence.meta.AnnotationProcessor6</processor>
</processors>
<outputDirectory>src/main/jpa-metamodel-generated</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
Then in my eclipse project, I click on properties->JPA and configure the Canonical metamnodel source folder to be the same as specified in my pom.xml (ie. src/main/jpa-metamodel-generated)
The other thing to be aware of, is when you do a build using maven, it will use a different annotation processor to generate the metamodel classes than eclipse uses. Eclipse uses Dali to generate these classes and Dali won't overwrite metamodel classes generated by a different annotation processor. It looks at the value of the @Generated annotation on the metamodel class and if its not "Dali" it won't overwrite it.
This means if you do a maven build on your project and then go back to eclipse and start modifying your entity classes, the metamodel classes won't automatically update unless you delete them and let eclipse regenerate them, which it does immediately. From then on, eclipse will automatically update the metamodel classes as you modify the entity classes, until you do the next 'mvn clean install'.
I think the Dali guys are going to provide a configuration option to allow you to specify Dali should overwrite these files. See http://www.eclipse.org/forums/index.php/t/236558/
Cheers,
Anthony
> From: max.andersen@xxxxxxxxxx
> Date: Thu, 15 Dec 2011 16:15:02 +0100
> To: m2e-users@xxxxxxxxxxx
> Subject: Re: [m2e-users] Annotation processing in Eclipse
>
> We got it compiled and working but also haven't been able to reach the contributor to be able to release it :(
>
> If anyone know karl@xxxxxxxxxxxxxxxxxxxx let him know he got emails awaiting ;)
>
> p.s. the workaround is to setup the annotation processor manually and commit the .settings files
> and it will work since m2e currently does not touch these settings.
>
> /max
>
> On Dec 15, 2011, at 12:17, Igor Fedorenko wrote:
>
> > Somebody provided a patch [1], but I could not get the patch working
> > cleanly in my environment and there was no response from the developer
> >
> > [1] https://bugs.eclipse.org/bugs/show_bug.cgi?id=335036
> >
> > --
> > Regards,
> > Igor
> >
> > On 11-12-15 2:13 AM, Ittai Zeidman wrote:
> >> Hi,
> >> I'm using m2e 1.0.100 and Eclipse (Indigo SR1).
> >> I'd like to know how I can get m2e to change my project configuration so
> >> that it uses "Annotation processing" when it compiles my code.
> >> The reason for this need is that I want to use the JPA feature of the
> >> canonical metamodel, which builds on annotation processing.
> >> I followed this hibernate tutorial
> >> <http://docs.jboss.org/hibernate/stable/jpamodelgen/reference/en-US/html_single/>
> >> and got maven itself to generate the required additional files without a
> >> problem but because Eclipse has no knowledge of these files, they are
> >> only in the target folder, then I cannot use them while working.
> >> Is there a way m2e can update the project configuration with respect to
> >> this aspect?
> >>
> >> Thanks in advance.
> >>
> >> --
> >> Ittai Zeidman
> >> VP R&D, Fashion Traffic <http://fashiontraffic.com/>
> >> Follow us on: Twitter <http://twitter.com/fashiontraffic>| Facebook
> >> <http://www.facebook.com/newfashiontraffic>| Tumblr
> >> <http://fashiontrafficblog.tumblr.com/>
> >>
> >>
> >>
> >> _______________________________________________
> >> m2e-users mailing list
> >> m2e-users@xxxxxxxxxxx
> >> https://dev.eclipse.org/mailman/listinfo/m2e-users
> > _______________________________________________
> > m2e-users mailing list
> > m2e-users@xxxxxxxxxxx
> > https://dev.eclipse.org/mailman/listinfo/m2e-users
>
> /max
> http://about.me/maxandersen
>
>
>
> _______________________________________________
> m2e-users mailing list
> m2e-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/m2e-users