-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Eclipse AJDT plugin + lombok don't work together #995
Comments
👍 |
I am also getting the same error:
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. Does anybody have an idea ? |
Just do it
|
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 but then it eithers breaks eclipse and/or intellij |
@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. |
@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 wrporter/lombok-aspectj#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 with the properties and with the dependencies |
Beware: that
|
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 |
@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. |
@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:
For 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.
Should this just be ignored? Also are you using lombok-maven-plugin? |
I'm actually getting this on IntelliJ with
|
@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? |
@kkman2008 See #995 (comment) together with my guide in #995 (comment) |
@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 |
STEPS:
|
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
:
[ERROR] log cannot be resolved
D:\xxxxx.java:133
log.info("-------success:" + applicationId);
The text was updated successfully, but these errors were encountered: