Project Lombok & AspectJ co-existence ?

2,267 views
Skip to first unread message

Setya

unread,
Jul 6, 2011, 11:00:00 PM7/6/11
to Project Lombok
Hi,

I have a project within Eclipse with project Lombok installed but as
soon as I convert that project into AspectJ project, the getters/
setters previously generated by project Lombok no longer exist. As far
as I understand, once a project converted to AspectJ project the class
compilation is taken over by AspectJ, hence Lombok doesn't have a
chance to intervene here, or does it ?

Any help would be greatly appreciated here.

Thanks & Regards,

Setya

rjee

unread,
Jul 8, 2011, 2:19:38 PM7/8/11
to Project Lombok
Hey,

we have had issues logged before about using the Spring aspect tooling
(http://code.google.com/p/projectlombok/issues/detail?id=23), so it's
not a big surprise that there would be issues with using AspectJ. What
we're missing is some experience with AspectJ (or some time to take a
stab at it).

If we had a running setup, we could see how the AspectJ compiler works
and how we could 'intervene'

any help here would be appreciated.

Setya

unread,
Jul 9, 2011, 1:46:38 AM7/9/11
to project...@googlegroups.com, rjee
Hi,

We have managed to get Project Lombok & AspectJ working together. But it
feels more like a workaround than clean solution.

First of all we don't convert the project into AspectJ project. But
after compiling we re-compile the classes using iajc via Ant to weave
classes, although more cumbersome caused by extra compilation step, this
works OK for now.

Thanks & Regards,

Setya

Fabrizio Giudici

unread,
Jul 14, 2011, 5:18:04 AM7/14/11
to project...@googlegroups.com, Setya, rjee
> Hi,
>
> We have managed to get Project Lombok & AspectJ working together. But
> it feels more like a workaround than clean solution.
>
> First of all we don't convert the project into AspectJ project. But
> after compiling we re-compile the classes using iajc via Ant to weave
> classes, although more cumbersome caused by extra compilation step,
> this works OK for now.
I'm seeing the same problem as I'm trying for the first time Lombok,
AspectJ and Maven at the same time. So, if I understand well the Ant
approach you used, you're basically postponing the intervention of the
AOP compiler, right?
Maybe I can try changing the binding of the AOP compiler with another
Maven phase.

--
Fabrizio Giudici - Java Architect, Project Manager
Tidalwave s.a.s. - "We make Java work. Everywhere."
java.net/blog/fabriziogiudici - www.tidalwave.it/people
Fabrizio...@tidalwave.it

Fabrizio Giudici

unread,
Jul 14, 2011, 6:14:32 AM7/14/11
to project...@googlegroups.com, Setya, rjee
> I'm seeing the same problem as I'm trying for the first time Lombok,
> AspectJ and Maven at the same time. So, if I understand well the Ant
> approach you used, you're basically postponing the intervention of the
> AOP compiler, right?
> Maybe I can try changing the binding of the AOP compiler with another
> Maven phase.
>

Ok, that was half solution. The problem is that with the aspectj-maven
plugin the AOP compiler always sees sources, thus recompiles them,
trashing Lombok changes. Unfortunately the Maven plugin doesn't support
binary weaving, so I've resorted to using the maven-ant plugin to
control how the AOP compiler is called:

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>${tft.aspectjrt.version}</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjtools</artifactId>
<version>${tft.aspectjrt.version}</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>weave-classes</id>
<phase>process-classes</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<taskdef
resource="org/aspectj/tools/ant/taskdefs/aspectjTaskdefs.properties"

classpathref="maven.plugin.classpath" />
<iajc

destDir="${project.build.directory}/classes"

inpath="${project.build.directory}/classes"
source="${tft.javac.source}"
target="${tft.javac.target}"

aspectPath="${org.springframework:spring-aspects:jar}"
classpathRef="maven.compile.classpath"
Xlint="ignore" />
</target>
</configuration>
</execution>
<execution>
<id>weave-test-classes</id>
<phase>process-test-classes</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<taskdef
resource="org/aspectj/tools/ant/taskdefs/aspectjTaskdefs.properties"

classpathref="maven.plugin.classpath" />
<iajc

destDir="${project.build.directory}/test-classes"

inpath="${project.build.directory}/test-classes"
source="${tft.javac.source}"
target="${tft.javac.target}"

aspectPath="${org.springframework:spring-aspects:jar}"
classpathRef="maven.compile.classpath"
Xlint="ignore" />
</target>
</configuration>
</execution>
</executions>
</plugin>

I'm not an expert of the AOP compiler, but basically the trick is not to
specify the srcDir, so it can't find the java sources, but the inpath
which allows it to find the compiled bytecode. I suppose it's the same
solution suggested by Setya, can you please confirm?


BTW - there's a patch in the aspectj-maven compiler that, AFAIU, would
introduce the required support in the plugin, but it has lingered for
1000+ days before being merged:

http://jira.codehaus.org/browse/MASPECTJ-9


In any case, it seems that the 1.4 version of the plugin will have it.

Reply all
Reply to author
Forward
0 new messages