You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by "Lewis, Eric" <Er...@ipi.ch> on 2011/01/13 16:48:14 UTC
How to write a plugin that generates source files based on the
source in the project?
Hi
I'm trying to write a plugin which does the following:
- Check the classes in the project and keep all classes that implement interface X.
- For all X, get the fields, and if a field has a certain annotation, generate a class containing some constant information.
Normally the plugin should be bound to the phase 'generate-sources'. However, the classes of the project aren't compiled yet at that moment, so I can't just get them from the classpath, right?
Does anyone have a good idea or pointers how to do this correctly?
Thanks & best regards,
Eric
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: How to write a plugin that generates source files based on the
source in the project?
Posted by Lucas Persson <lu...@oracle.com>.
xdoclet is a tool for parsing java and also generate java, but it is
kind of old now
/Lucas
On 01/13/2011 04:48 PM, Lewis, Eric wrote:
> Hi
>
> I'm trying to write a plugin which does the following:
>
> - Check the classes in the project and keep all classes that implement interface X.
> - For all X, get the fields, and if a field has a certain annotation, generate a class containing some constant information.
>
> Normally the plugin should be bound to the phase 'generate-sources'. However, the classes of the project aren't compiled yet at that moment, so I can't just get them from the classpath, right?
>
> Does anyone have a good idea or pointers how to do this correctly?
>
> Thanks& best regards,
> Eric
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
--
Oracle <http://www.oracle.com>
Lucas Persson | Principal Member of Technical Staff
Phone: +4684773644 <tel:+4684773644> | | | Mobile: +46730946656
<tel:+46730946656>
Oracle Communications Platform
ORACLE Sweden | Folkungagatan 122 | 116 30 Stockholm
Oracle Svenska AB, Kronborgsgränd 17, S-164 28 KISTA, reg.no. 556254-6746
Green Oracle <http://www.oracle.com/commitment> Oracle is committed to
developing practices and products that help protect the environment
Re : How to write a plugin that generates source files based on the source in the project?
Posted by Julien HENRY <he...@yahoo.fr>.
Hi,
You should try to use new JDK 1.6 annotation processor utilities. The only
constraint I see is that each class you want to "parse" must be annotated.
Regards,
Julien
----- Message d'origine ----
> De : "Lewis, Eric" <Er...@ipi.ch>
> À : "users@maven.apache.org" <us...@maven.apache.org>
> Envoyé le : Jeu 13 janvier 2011, 16h 48min 14s
> Objet : How to write a plugin that generates source files based on the source
>in the project?
>
> Hi
>
> I'm trying to write a plugin which does the following:
>
> - Check the classes in the project and keep all classes that implement
>interface X.
> - For all X, get the fields, and if a field has a certain annotation, generate
>a class containing some constant information.
>
> Normally the plugin should be bound to the phase 'generate-sources'. However,
>the classes of the project aren't compiled yet at that moment, so I can't just
>get them from the classpath, right?
>
> Does anyone have a good idea or pointers how to do this correctly?
>
> Thanks & best regards,
> Eric
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org