Annotation Processing for GWT using javax.annotation.processing. Alternatives, Compile tips ?

544 views
Skip to first unread message

zixzigma

unread,
Dec 27, 2010, 9:10:01 PM12/27/10
to Google Web Toolkit
I have defined a custom annotation in my GWT app,
and have annotated my classes with it.

I would like to process it and generate some code,
that rest of my app would depend on it.

1- do you think using this package:
javax.annotation.processing

is a good idea ? are there any alternatives ?
how does it compare to :com.google.gwt.core.ext ?

2- in terms of compiling, what is the best practice ?
should I process my annotations first and use the generated class
files to
then compile my GWT project? or this can be automated in one single
step ?


Thank You

Thomas Broyer

unread,
Dec 28, 2010, 6:54:08 AM12/28/10
to google-we...@googlegroups.com


On Tuesday, December 28, 2010 3:10:01 AM UTC+1, zixzigma wrote:
I have defined a custom annotation in my GWT app,
and have annotated my classes with it.

I would like to process it and generate some code,
that rest of my app would depend on it.

1- do you think using this package:
javax.annotation.processing

is a good idea ? are there any alternatives ?
how does it compare to :com.google.gwt.core.ext ?

GWT generators are only triggered by a GWT.create() in your code (and an appropriate <generate-with> rule in a gwt.xml)
 
2- in terms of compiling, what is the best practice ?
should I process my annotations first and use the generated class
files to
then compile my GWT project? or this can be automated in one single
step ?

I don't think it can be done in 1 step.
We do use an annotation processor (http://projectlombok.org) and we first generate the java files (using the dedicated maven plugin) that are then used by GWT (these are for our domain model classes, that we currently use with GWT-RPC). Each time we make a change to a model class, we have to re-generate the files for the change to be seen by GWT's DevMode.

Gal Dolber

unread,
Dec 28, 2010, 7:16:58 AM12/28/10
to google-we...@googlegroups.com
Guaw! great project


--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.



--
Guit: Elegant, beautiful, modular and *production ready* gwt applications.

http://code.google.com/p/guit/




Gal Dolber

unread,
Dec 28, 2010, 7:54:16 AM12/28/10
to google-we...@googlegroups.com
Thomas, 
where you been able to use lombok with gwt code?
I getting error while running (or compiling) on every call to a generated method.

[ERROR] [testapp] - Line 61: The method getMarketing() is undefined for the type Unit

Thomas Broyer

unread,
Dec 28, 2010, 8:05:37 AM12/28/10
to google-we...@googlegroups.com
Yes we do. You have to add the generated sources output dir to your classpath for GWT to see them, and make sure GWT doesn't see the "original" source files (either by putting them "later" on the classpath, or better not at all).

Here's our project layout (dictated by both Maven and the lombok-maven-plugin):
src/main/java -> source code that does not make use of lombok's annotations
src/main/lombok -> source code that uses lombok annotations
target/generated-sources/delombok -> output folder where "delomboked" files are generated

We then make sure to include target/generated-sources/delombok in the classpath, but not src/main/lombok.

Gal Dolber

unread,
Dec 28, 2010, 8:17:11 AM12/28/10
to google-we...@googlegroups.com
Thanks!!

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
Reply all
Reply to author
Forward
0 new messages