Home > Blockchain >  How to (quickly) replace all Lombok annotations with generated methods?
How to (quickly) replace all Lombok annotations with generated methods?

Time:01-23

I'm working on a Spring Boot project for university. The deadline is in a week and I'm 99% done with everything. Now, my instructor has reached out to me and asked me to remove Lombok from my project because (from how I understand it) he has a personal issue with it.

While I can't fathom why anyone would give such a requirement and really don't want to remove Lombok, I have to obey.

So now my question is: Is there a way to quickly replace all my Lombok annotations with its generated methods? If there is no way, I guess I'll have to resort to refactoring everything manually...

Thanks for any help.

CodePudding user response:

The Lombok .jar file provides a 'delombok' tool, which will process all of the Java files in a given directory and output the generated code to another directory.

The usage looks like this:

java -jar lombok.jar delombok src -d src-delomboked

There is also a Maven plugin for this.

Alternatively, if you're using IntelliJ, the Lombok plugin also provides this functionality, under 'Refactor' -> 'Delombok'.

I have just tested this out on one of my own projects, and the resulting code does not have any references to Lombok, so hopefully it will be enough to make your instructor happy :)

CodePudding user response:

What is the IDE you're using? Most IDEs have shotcuts for this. For instance, in Eclipse, you could generate Getters and Setters with "Right click" --> "Source" --> "Generate Getters and Setters"

  • Related