Open xiaolongzuo opened 8 years ago
:+1:
I am also getting the same error:
[ant:iajc] [warning] You aren't using a compiler supported by lombok, so lombok will not work and has been disabled.
[ant:iajc] Your processor is: org.aspectj.org.eclipse.jdt.internal.compiler.apt.dispatch.BatchProcessingEnvImpl
[ant:iajc] Lombok supports: sun/apple javac 1.6, ECJ
Seems like the combination of AspectJ and Lombok is not working properly.
Has anyone achieved the compilation of an Application using both with Gradle/Maven?
I'm having the same issue
Hi, erverybody. I'm facing the same issue (lombok 1.16.16, maven aspectj plugin 1.10). I've tried this, but without success.
Does anybody have an idea ?
Just do it
<build>
<sourceDirectory>${project.build.directory}/generated-sources/delombok</sourceDirectory>
<plugins>
<plugin>
<groupId>org.projectlombok</groupId>
<artifactId>lombok-maven-plugin</artifactId>
<version>1.16.16.0</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>delombok</goal>
</goals>
</execution>
</executions>
<configuration>
<addOutputDirectory>false</addOutputDirectory>
<sourceDirectory>src/main/java</sourceDirectory>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.10</version>
<configuration>
<complianceLevel>${java.version}</complianceLevel>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
reviving this zombie thread since I have not found a way to solve this under the context : eclipse, intellij, maven cmdline. It either works in 2 out of 3, never in all 3 at once.
it looks like something is missing : how do you setup the plugin to use the delomboked folder ? obviously I've tried the
@laurentperez What were your solutions? I can't seem to get it to work on any 1 of the 3 options. I use IntelliJ and the command line.
@wrporter I found no solution, but I still believe a solution lies under the delomboked sources, I just couldn't find it. I'm under idea/cmdline too. Workaround : remove lombok from the aspected classes, it's only sugar.
@laurentperez My sample project now compiles after removing Lombok from a class that uses AspectJ. However, I can only get Lombok to work or AspectJ to work, not both. Do you have a solution for that?
@wrporter I got it working, see your PR https://github.com/wrporter/lombok-aspectj/pull/1
I had this issue where aspecj and lombok together wasn't working. I had to move the aspectj pluin into Plugin management section and that resolved my issue. I have no idea what that really means but it did resolved my issue.
I am using this
`
<plugins>
<plugin>
<groupId>org.projectlombok</groupId>
<artifactId>lombok-maven-plugin</artifactId>
<version>1.16.16.0</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>delombok</goal>
</goals>
</execution>
</executions>
<configuration>
<addOutputDirectory>false</addOutputDirectory>
<sourceDirectory>src/main/java</sourceDirectory>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.11</version>
<configuration>
<aspectLibraries>
<aspectLibrary>
<groupId>io.astefanutti.metrics.aspectj</groupId>
<artifactId>metrics-aspectj</artifactId>
</aspectLibrary>
</aspectLibraries>
<complianceLevel>1.8</complianceLevel>
<source>1.8</source>
<target>1.8</target>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
`
with the properties
`
Beware: that <sourceDirectory>${project.build.directory}/generated-sources/delombok</sourceDirectory>
might screw your IDE since it'll add that folder to source directory list and you might get "duplicate sources were found" issue.
This one works properly for me:
<plugin>
<!--
<groupId>org.codehaus.mojo</groupId>
Using snapshot build instead: https://github.com/mojohaus/aspectj-maven-plugin/issues/24#issuecomment-419077658
-->
<groupId>com.github.m50d</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.11.1</version>
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>${aspectj.version}</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjtools</artifactId>
<version>${aspectj.version}</version>
</dependency>
</dependencies>
<configuration>
<complianceLevel>${maven.compiler.target}</complianceLevel>
<source>${maven.compiler.target}</source>
<target>${maven.compiler.target}</target>
<showWeaveInfo>true</showWeaveInfo>
<verbose>true</verbose>
<Xlint>ignore</Xlint>
<encoding>${project.build.sourceEncoding}</encoding>
<forceAjcCompile>true</forceAjcCompile>
<sources/><!-- this is important!-->
<weaveDirectories>
<weaveDirectory>${project.build.directory}/classes</weaveDirectory>
</weaveDirectories>
</configuration>
<executions>
<execution>
<phase>process-classes</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
any updates? this is so important :D
any updates? this is so important :D
@symonk I don't think it is lombok's fault for incompatibility, but aspect's aj compiler.
I've moved to google guice for some AOP and it seems to work great with lombok
+1
I had this issue where aspecj and lombok together wasn't working. I had to move the aspectj pluin into Plugin management section and that resolved my issue. I have no idea what that really means but it did resolved my issue.
@senthil-r The pluginManagement element in pom.xml is intended to configure project builds that inherit from this one, but not declaring an to-be-used plugin in current projects and its dependent projects. In another word, you are just not using AspectJ compiler.
google guice
@symonk could you share the pom.xml code to weave at compile time using google guice?
Posting again with a different user:
Workaround for all Eclipse users struggling with AJDT (AspectJ plugin) interfering with Lombok:
The AspectJ maven plugin configuration provided by @izogfif solves build errors during maven builds, but AJDT still uses a different configuration and compiles the files in src/main/java using ajc instead of doing bytecode (class file) weaving like the aspectj-maven-plugin with the configuration from above.
I have found no way to tell AJDT to not compile the source files without breaking the classpath of the Eclipse project. You can specify the locations of additional classes and jar files to inject your aspects into, but you can't remove the default locations of src/main/java and src/test/java.
What I did instead to solve the problem was:
<pluginManagement><plugins>
) with <ignore></ignore>
for the aspectj-maven-plugin, change it to <execute />
so Aspects work in the Eclipse debugger and JUnit testsFor me this workaround was acceptable because I had only one small aspect in .aj form in my project and seeing the AspectJ indicators provided by AJDT isn't that useful.
Also, no matter what the internet says, you don't (!!) need any extra configuration files or Spring to make AspectJ annotations work. You can do compile-time and bytecode weaving the same way as with .aj files.
The majority of the search results for "AspectJ annotations bytecode weaving" lead to guides for compile-time weaving with AspectJ annotations, load-time weaving with Spring, or bytecode weaving with .aj files.
@bergerst Hi could you please share the changes made in pom.xml?
@junhuhdev The pom.xml uses the snippet provided by izogfif above. It works as long as you don't build with Eclipse.
I only made changes by converting the .aj files into annotated Aspect classes and removing AJDT so Eclipse can compile the projects.
@bergerst Ok, I have similar setup using annotated aspect classes. Tests and builds are running fine, but I am getting this during build.
[INFO] --- aspectj-maven-plugin:1.10:test-compile (default) @ ---
[INFO] Showing AJC message detail for messages of types: [error, warning, fail]
[WARNING] You aren't using a compiler supported by lombok, so lombok will not work and has been disabled.
Your processor is: org.aspectj.org.eclipse.jdt.internal.compiler.apt.dispatch.BatchProcessingEnvImpl
Lombok supports: sun/apple javac 1.6, ECJ
<unknown source file>:<no line information>
Should this just be ignored? Also are you using lombok-maven-plugin?
I'm actually getting this on IntelliJ with lombok
and jcabi-aspects
together
SLF4J: The following loggers will not work becasue they were created
SLF4J: during the default configuration phase of the underlying logging system.
SLF4J: See also http://www.slf4j.org/codes.html#substituteLogger
@junhuhdev That probably means that AJDT is still activated for your project. Right click on the project -> AspectJ -> Remove AspectJ capability. Then it should work.
If it still doesn't work, is Lombok set as java agent in the eclipse.ini file?
What's conclusion? How to make Lombok work with aspectJ? It could work, please look the below link as reference: https://palesz.wordpress.com/2011/12/03/howto-maven-lombok-and-aspectj-together/
@kkman2008 See https://github.com/rzwitserloot/lombok/issues/995#issuecomment-421081283 together with my guide in https://github.com/rzwitserloot/lombok/issues/995#issuecomment-470108271
@cooligc The question is already answered by me, the only thing missing is either:
But since it's been 1 1/2 years since my comment, I don't think that anyone else will come up with a better solution.
@bergerst It sounds like your guide is mostly a setup to eliminate aspectj from your sourcebase, but I get the feeling I'm not fully grokking this guide.
I'm open for adding something to the 'setup' section of the website at least, possibly improve that error folks are getting so that it mentions that link.
@rzwitserloot No, you misunderstood.
The steps by izogfif probably work for IntelliJ IDEA, but Eclipse has an AspectJ plugin called AJDT which interferes with Lombok. Necessary code changes in the AJDT plugin will never happen since its community is dead, so disabling AJDT is the only option.
My additional steps do exactly that. After that, Eclipse will produce lots of compiler errors because it doesn't know how to handle AspectJ-.java files if the project uses those.
However, AspectJ can be added to a project in 2 ways:
The capabilities are the same for both, but the format is different.
If you reproduce the .java content in .aj files, Eclipse doesn't know how to handle the .aj files and ignores them. However, the aspectj-maven-plugin will still use them during Eclipse maven builds.
@bergerst ahhh - okay, now I'm starting to understand how it works!
Do you think it's worthwhile to add a full guide for this? I'm definitely thinking the error message should be better (and we can probably outright detect this scenario and write an error message accordingly, I'm sure the actual processor instance is a specific class from AJDT or something else unique to the AJDT scenario we can detect), but a guide to effectively turn eclipse into notepad.exe
by taking your aspectJ-ified java code and ensuring eclipse treats them as plain text files (no highlighting, no compiling, no debugging, no HCR, no search tools, no refactor scripts, no outlines...) doesn't seem like something we actively want to suggest. That feels like curing a toothache by shooting the patient in the face: That's.. not much of a cure.
STEPS:
/website
, probably under setup (entry Eclipse-AJDT perhaps?), with a link from the eclipse setup description. Include the full error message so people can easily find it when searching for the error. Include @bergerst's texts as basis for what this page should look like.Beware: that
<sourceDirectory>${project.build.directory}/generated-sources/delombok</sourceDirectory>
might screw your IDE since it'll add that folder to source directory list and you might get "duplicate sources were found" issue. This one works properly for me:<plugin> <!-- <groupId>org.codehaus.mojo</groupId> Using snapshot build instead: https://github.com/mojohaus/aspectj-maven-plugin/issues/24#issuecomment-419077658 --> <groupId>com.github.m50d</groupId> <artifactId>aspectj-maven-plugin</artifactId> <version>1.11.1</version> <dependencies> <dependency> <groupId>org.aspectj</groupId> <artifactId>aspectjrt</artifactId> <version>${aspectj.version}</version> </dependency> <dependency> <groupId>org.aspectj</groupId> <artifactId>aspectjtools</artifactId> <version>${aspectj.version}</version> </dependency> </dependencies> <configuration> <complianceLevel>${maven.compiler.target}</complianceLevel> <source>${maven.compiler.target}</source> <target>${maven.compiler.target}</target> <showWeaveInfo>true</showWeaveInfo> <verbose>true</verbose> <Xlint>ignore</Xlint> <encoding>${project.build.sourceEncoding}</encoding> <forceAjcCompile>true</forceAjcCompile> <sources/><!-- this is important!--> <weaveDirectories> <weaveDirectory>${project.build.directory}/classes</weaveDirectory> </weaveDirectories> </configuration> <executions> <execution> <phase>process-classes</phase> <goals> <goal>compile</goal> </goals> </execution> </executions> </plugin> </plugins>
nice, solved my problem, thanks.
I use aspectJ compiler,then get error below(the @log4j is unavailable).Is there anyway to fixed?
[WARNING] You aren't using a compiler supported by lombok, so lombok will not work and has been disabled. Your processor is: org.aspectj.org.eclipse.jdt.internal.compiler.apt.dispatch.BatchProcessingEnvImpl Lombok supports: sun/apple javac 1.6, ECJ