Open thekalinga opened 6 years ago
Note that the same configuration works fine in IntelliJ Idea. Just that I manually add annotation processor options over there
As per the author of gradle-apt-plugin
plugin, STS is configured properly. Which leaves us with two options
Please let me know which one it is
@kdvolder can you have a look and provide a bit of help? Thanks!!!
I don't really know why it wouldn't be working. I can only make wild guesses.
Besides the two options above there is also a third one.
It really anyone's guess what is going wrong here. It may require to actually debug the annotation processors themselves to see why they aren't working. Maybe some experiments can be done to try and get more information.
One thing could try is if it works correctly in a 'vanilla' eclipse with buildship. (I.e. without any additions from STS). If it works there then its probably something in STS causing this.
Another thing could be tried is to remove some pieces from the setup you have. Perhaps we can to try to isolate and pinpoint the problem. For example... can you get the mapstruct processor to work by itself (i.e. without introducing lombok in the mix as well). Similarly can you get lombok processor to work by itself?
Finally... I am a bit surprised that you are trying to use lombok as an annotation processor inside of Eclipse. I have not seen anyone else try that before. Typically people using lombok in Eclipse install something directly into eclipse (lombok provides an installer that will modify your eclipse, under the hood it adds a java agent to Eclipse's startup which actually modifies/patches the eclipse compiler). I'm not sure that just configuring the annotation processor designed for CLI use is expected to work in Eclipse environment (as noted earlier, eclipse compiler is more complex than the typical CLI invocation of Javac and many annotation processor do not work properly). Here's some info about the setup of lombok with the java agent https://howtodoinjava.com/automation/lombok-eclipse-installation-examples/
I also found this via google and the official mapstruct website:
https://marketplace.eclipse.org/content/mapstruct-eclipse-plugin
So it seems, both mapstruct and lombok are providing another mechanism than an annotation processor to be able to integrate with Eclipse. Perhaps annotation processor are simply not the right way to get them working properly inside of Eclipse?
@kdvolder The plugin does not do the compilation part. It parses the POJOs in the classpath & shows suggestions in IDE when writing mappings using mapstruct
Lombok is required when we need to build from the terminal using gradle. Is there another way to build without lombok as a annotation processor dependency?
I just tried in the latest version of eclipse. Have the same issue
Where can I open the issue for this?
Added more information to an existing eclipse issue
Lombok is required when we need to build from the terminal using gradle. Is there another way to build without lombok as a annotation processor dependency?
No I think you will always need the annotation processors to be part of your gradle build for the build on the CLI to work. I was just questioning whether you need it to work inside of Eclipse too. While I don't use lombok myself I just happened to be aware of the lombok Eclipse extension that some people use to get lombok <-> eclipse integration.
Where can I open the issue for this?
You can try raising several places. Bug against buildship or jdt-apt via https://bugs.eclipse.org/. I see you already tried filing against gradle-apt plugin. You could also try lombok and/or mapstruct.
The trouble is though its not quite clear where to lie blame just yet. Is it BuildShip for not properly configuring the project (or maybe rather the 'gradle-apt-plugin')? Or is it JDT APT which is not properly supporting the two annotation processors you are trying to use, despite them being properly configured? Or is it the lombok and mapstruct processors that might be doing something that doesn't work in Eclipse that they could change (I am reluctant to say that mapstruct / lombok are doing something actually 'wrong' because obviously it works on the CLI, but the fact is that Eclipse incremental compile is more complex than a typical CLI build and it might require special consideration from the processor authors).
There is also still this... There are tools to integrate lombok and mapstruct with Eclipse. So clearly you aren't the first person to try to do that. So its bit surprising it doesn't work for you, and seems there should probably be a way to set these things up so they do actually work properly from Eclipse and the CLI both. I'm just not sure I have much more to offer to help you with that as don't use them myself, and if you are doing something 'wrong' its certainly not obvious to me what it might be.
@kdvolder Thanks for your response. I'll for the eclipse team to respond
I created a sample project that integrated lombok + mapstruct + gradle + STS (with buildship plugin). The sample project is located at https://github.com/thekalinga/gradle-apt-plugin-eclipse-issue
But, STS does not generate classes using
mapstruct
despite the annotation processor being available in the dependencies & exposed via facory paths. I'm unable to figure out what could be causing this issueWould appreciate if you could help me decide whether the issue is with the plugin/something I did (or) did not do/with IDE
Here are the steps I followed
Imported the project into STS using
Gradle -> Existing Gradle Project
, I ran./gradlew eclipseJdtApt eclipseFactorypath
from terminal & refreshed the project in eclipse. Then I tried cleaning & rebuilding the project. No files are being generated under.apt_generated
I see proper values set w.r.t project properties. Here are the screenshots of the settings
Properties -> Java Compiler
Properties -> Java Compiler -> Annotation Processing
Properties -> Java Compiler -> Annotation Processing -> Factory Path
I'm using STS with lombok plugin installed. You can see this
Help -> About Spring Tool Suite
The project can be tested from terminal by running
./gradlew bootRun
. You would see a log messageIdentity Tranformation value is 10
in the consoleThe same cannot be done from STS as I'm not able to make annotation processors to work
Reproducing the issue I opened earlier in the plugin repo