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 - Java Architect, Project Manager
Tidalwave s.a.s. - "We make Java work. Everywhere."
java.net/blog/fabriziogiudici - www.tidalwave.it/people
Fabrizio...@tidalwave.it
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.