Using lombok with Maven Tycho

653 views
Skip to first unread message

Rabea Gransberger

unread,
May 28, 2011, 12:54:32 PM5/28/11
to project...@googlegroups.com
Hello,

I'm still trying to use lombok with Maven Tycho to be able to
automatically build my eclipse RCP projects which are using lombok in
several places.

Because it's not possible to use them together out of the box, I've been
looking at the sources of both to find a way to run a simple build
successfully.

I need to understand how lombok is working inside eclipse. Why is it
registered as agent and not used as simple annotation processor?

If I use it in a RCP project, the project will have a dependency to the
lombok.jar. Therefore it is on the classpath and will be picked up as
annotation processor during build if Java 1.6 is used. Tycho uses the
eclipse batch compiler (org.eclipse.jdt.internal.compiler.batch.Main)
and the
org.eclipse.jdt.internal.compiler.apt.dispatch.BatchProcessingEnvImpl as
APT ProcessingEnvironment. Using this configuration lombok responds with

"You should not install lombok.jar as an annotation processor in
eclipse. Instead, run lombok.jar as a java application and follow the
instructions."

I tried to use a new ProcessorDescriptor within
lombok.core.AnnotationProcessor to ignore the warning and patch the
ClassLoader similiar to the JavacProcessor. This gives me the "We
believe you may have just stumbled on lombok issue #164." warning issued
in method
lombok.eclipse.handlers.EclipseHandlerUtil.injectMethod(EclipseNode,
AbstractMethodDeclaration) and will totally break the compilation process.

I did also try to use the java agent and bootclasspath paramters, as
used when running eclipse normally. But the eclipse batch compiler does
not recognize these parameters and hence this also won't work.

I'm willing to get this running, because I don't know of any other
options to build my projects at this point. Another idea might be to
use delombok before tycho picks up. I didn't try this yet and don't know
if it will work...

If you like to have a look at it, I can give you a simple Maven based
project which demonstrates the described problems.

Regards,
Rabea

Reinier Zwitserloot

unread,
May 28, 2011, 1:41:00 PM5/28/11
to project...@googlegroups.com
Because lombok isn't an annotation processor. Lombok is a compiler hack. It has to worm its way into the compiler one way or another. We can do so during the init() phase of an annotation processor in javac.

All lombok versions you can download (but not what you can build from master right now IIRC) also think they can do this trick to ecj, but it turns out they actually can't. There are relatively obscure source constructs that simply break down if lombok is registered as an annotation processor in ecj. We see now short-term way to fix this so for the 0.10.0 release we'll have to disable that aspect, unfortunately.

On the plus side, registering lombok as an agent will actually work for ecj pretty soon. It's not exactly convenient, but at that point, you can use lombok with ecj or any ecj-related offshoot (such as tycho!) by making sure lombok.jar is registered as agent as the JVM that ends up running tycho is started. This doesn't play nice with something like an ecj ant task, unfortunately (no easy way to specify an agent other than with jvmargs), but we don't have a better solution. On the plus side, this means lombok can be combined with GWT and Play Framework, and with some extra effort, Tycho too.

Rabea Gransberger

unread,
May 28, 2011, 1:53:38 PM5/28/11
to project...@googlegroups.com
Thank you for that information. So lombok won't currently work with
tycho because it doesn't work with ecj correctly...

Do you have an issue in the bug tracker regarding this topic, so that I
can register for that to stay up to date with any ongoing work?


Reinier Zwitserloot schrieb:

> --
> You received this message because you are subscribed to the Google
> Groups group for http://projectlombok.org/
>
> To post to this group, send email to project...@googlegroups.com
> To unsubscribe from this group, send email to
> project-lombo...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/project-lombok?hl=en

Reinier Zwitserloot

unread,
May 29, 2011, 12:38:38 AM5/29/11
to project...@googlegroups.com

Nat

unread,
Sep 23, 2016, 3:58:12 AM9/23/16
to Project Lombok
Any updates on this one? I have run into the same problem. Declaring an annotation processor does not seem to work even though the bug has been fixed.

On Saturday, May 28, 2011 at 9:38:38 PM UTC-7, Reinier Zwitserloot wrote:
http://code.google.com/p/projectlombok/issues/detail?id=212
Reply all
Reply to author
Forward
0 new messages