Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Lombok on Jenkins

I just started using Lombok's ability to auto-generate getters and setters for Java beans in my local Eclipse environment via modifying its boot classpath:

-vmargs -javaagent:lombok.jar -Xbootclasspath/a:lombok.jar

It works fine locally, however since our application lifecycle entails Jenkins builds I'm a little suspicious of the manner in which those @Getter and @Setter annotations affect the code when it will run in our CI environment.

So far Lombok touches our domain layer and since we use other frameworks which are dependent on having getters/setters on the model at runtime for them to work I'd like to have a bit more understanding on how Lombok's bytecode modification is done before I fully commit to its usage.

Will all the methods that those annotations auto generate be available in Jenkins just by virtue of having Lombok's dependency in the pom.xml file or will I additionally need to modify the whole Jenkins' startup script as above. Or perhaps just Jenkins job will need to be somehow modified to incorporate Lombok's bytecode modification behavior?

If someone tried and succeeded incorporating Lombok with Jenkins CI, I'll be willing to hear their experience and assimilate them into our DevOps process.

Thank you in advance.

like image 524
Simeon Leyzerzon Avatar asked Dec 02 '15 14:12

Simeon Leyzerzon


1 Answers

Having a Lombok dependency in your pom file ("provided") should do the job. You can test this on the command line on your local machine using mvn package. You don't need the -vmargs or anything else.

Lombok hooks in at the compile phase and just generates the right fields, methods and code in the classfile. Everything that works on classfiles doesn't even need to know it was generated by Lombok.

If for some reason you need to process the source files that contain the generated code, you can also first run delombok using the Lombok Maven Plugin.

At my company we use Jenkins and Lombok succesfully.

Disclosure: I am a Lombok developer.

like image 61
Roel Spilker Avatar answered Sep 30 '22 16:09

Roel Spilker