Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [m2e-dev] Annotations Processing Contribution

Karl's been working on the patch attached to https://bugs.eclipse.org/bugs/show_bug.cgi?id=335036
In this case, annotation processing is not delegated to maven plugins but to the eclipse APT
I did experiments on my own from his patch and was able to build infinispan-core and hibernate-search, which use jpamodelgen and/or the jboss-logging-generator successfully.



2011/7/11 Eric Dalquist <eric.dalquist@xxxxxxxxxxxxx>
So the alternative is to use the org.bsc.maven:maven-processor-plugin. An example of that approach can be found in the jpa-metamodel profile here: https://source.jasig.org/uPortal/trunk/uportal-war/pom.xml

The maven-processor-plugin produces the same output but the build is slower for large projects because the includes in the processor plugin don't really work. For a project like uPortal with 1100+ class files with only 31 that have annotations that need processing its nice to be able to only process the classes that need it.

I'm really liking the new m2e plugin and would be more than happy to help get annotation processing working. For now I'm getting the feeling that the most expedient approach is going to be to write a m2e extension for the maven-processor-plugin?

Thanks for the help,
-Eric



On 07/11/2011 11:21 AM, Igor Fedorenko wrote:
FYI, there is some code attached to [1], but we have not figured out how
to do annonations processing in non-intrusive manner, i.e. only enable
it for users who actually need it and ignore it for everyone else.

Do you have some other maven plugin goal to trigger annotation
processing enablement?

[1] https://bugs.eclipse.org/bugs/show_bug.cgi?id=335036

--
Regards,
Igor

On 11-07-11 6:38 PM, Eric Dalquist wrote:
That's what I had originally figured. The part I'm a little confused
about is can I write a m2e extension for the maven-compiler-plugin since
m2e doesn't flag the extra execution as an error but also doesn't ever
run it:

<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<compilerArgument>-proc:none</compilerArgument>
</configuration>
<executions>
<execution>
<id>run-annotation-processors-only</id>
<phase>generate-sources</phase>
<configuration>
<compilerArgument>-proc:only</compilerArgument>
<includes>
<include>org/jasig/portal/**/dao/jpa/*.java</include>
<include>org/jasig/portal/layout/dlm/*.java</include>
<include>org/jasig/portal/layout/dlm/providers/*.java</include>
</includes>
</configuration>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>

This config works just find from the command line but m2e doesn't seem
to acknowledge that the generate-sources execution exists and I'm a
little wary about writing a plugin since the compiler plugin already has
lifecycle mapping information for it from what I've read.

-Eric

On 7/9/11 4:09 PM, Jeff MAURY wrote:
In that case, you need to develop a M2E extension for your plugin.

Regards
Jeff


On Sat, Jul 9, 2011 at 2:09 PM, Eric Dalquist
<eric.dalquist@xxxxxxxxxxxxx <mailto:eric.dalquist@doit.wisc.edu>> wrote:

   Yeah I found that and it does work. The problem is there is no
   extension for either the maven-processor-plugin or for running the
   compiler during the generate-sources phase. If I run "mvn clean
   compile" on the command line and then refresh my eclipse project
   the build helper plugin correctly adds the
   "target/generated-sources/annotations" directory as a source dir.
   The problem is without running the command line build the compiler
   is not run to generate that directory and the sources.

   -Eric


   On 7/9/11 2:25 AM, Jeff MAURY wrote:
   I think there is a M2E extension that deals with the build helper
   plugin. So given your configuration, I don't think there is more
   to do.
   Regards
   Jeff


   On Sat, Jul 9, 2011 at 4:55 AM, Eric Dalquist
<eric.dalquist@xxxxxxxxxxxxx
<mailto:eric.dalquist@doit.wisc.edu>> wrote:

       Note while doing some more digging I found a more concise way
       to do the annotation processor config:
       http://planet.jboss.org/view/post.seam?post=a_more_concise_way_to_generate_the_jpa_2_metamodel_in_maven

       So even better would be to work on a m2e extension that
       allows the compiler and build-helper plugins to run at the
       correct time in eclipse. Again I'm more than happy to do this
       work I'm just looking for any tips or other ideas before
       getting started.

       -Eric


       On 7/8/11 9:30 PM, Eric Dalquist wrote:
       I have a project that uses the hibernate-jpamodelgen library
       to generate code based on annotations. We had this working
       for our project under the old m2eclipse plugin by using the
       maven-processor-plugin and build-helper-maven-plugin, I've
       included the config below.

       I'm interested in helping figure out the best way to do this
       and write the m2e plugin to get it working. I've looked over
       the source for the m2e jaxb feature that was created for
       this issue:
       https://bugs.eclipse.org/bugs/show_bug.cgi?id=350299 that
       gives me some ideas but before I started playing with code I
       was wondering if anyone here had any words of wisdom to share.

       Thanks,
       -Eric

<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<compilerArgument>-proc:none</compilerArgument>
</configuration>
</plugin>
<plugin>
<groupId>org.bsc.maven</groupId>
<artifactId>maven-processor-plugin</artifactId>
<version>2.0.2</version>
<executions>
<execution>
<id>process</id>
<goals>
<goal>process</goal>
</goals>
<phase>generate-sources</phase>
<configuration>
<outputDirectory>target/generated-sources/metamodel</outputDirectory>

</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>target/generated-sources/metamodel</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>


       _______________________________________________
       m2e-dev mailing list
       m2e-dev@xxxxxxxxxxx <mailto:m2e-dev@xxxxxxxxxxx>
       https://dev.eclipse.org/mailman/listinfo/m2e-dev

       _______________________________________________
       m2e-dev mailing list
       m2e-dev@xxxxxxxxxxx <mailto:m2e-dev@xxxxxxxxxxx>
       https://dev.eclipse.org/mailman/listinfo/m2e-dev




   --
   "Legacy code" often differs from its suggested alternative by
   actually working and scaling.
   - Bjarne Stroustrup

   http://www.jeffmaury.com
   http://riadiscuss.jeffmaury.com
   http://www.twitter.com/jeffmaury


   _______________________________________________
   m2e-dev mailing list
   m2e-dev@xxxxxxxxxxx <mailto:m2e-dev@xxxxxxxxxxx>
   https://dev.eclipse.org/mailman/listinfo/m2e-dev

   _______________________________________________
   m2e-dev mailing list
   m2e-dev@xxxxxxxxxxx <mailto:m2e-dev@xxxxxxxxxxx>
   https://dev.eclipse.org/mailman/listinfo/m2e-dev




--
"Legacy code" often differs from its suggested alternative by actually
working and scaling.
- Bjarne Stroustrup

http://www.jeffmaury.com
http://riadiscuss.jeffmaury.com
http://www.twitter.com/jeffmaury


_______________________________________________
m2e-dev mailing list
m2e-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/m2e-dev


_______________________________________________
m2e-dev mailing list
m2e-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/m2e-dev
_______________________________________________
m2e-dev mailing list
m2e-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/m2e-dev


_______________________________________________
m2e-dev mailing list
m2e-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/m2e-dev




--
"Have you tried turning it off and on again" - The IT Crowd

Back to the top