1

This question is about at how during maven build process is Lombok adding additional code during compile process.

I have been using Lombok for some time and am to some extent aware about it's features. If i look back at few good starter tutorials for Lombok, like this, they advice on using the below dependency

<dependencies>
    ...
    <dependency>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
        <version>1.18.20</version>
        <scope>provided</scope>
    </dependency>
    ... 
</dependencies>

(For eclipse additional setup is required which is not my concern here. )

  1. So now with the above dependency added, if i do a mvn clean compile, will the boiler plate code be added to the generated class files.
  2. If it does, how is this happening as there is no maven-compile stage plugin being added in the plugin section.

Above questions are based on the fact that Lombok code is added at compile time and not at run time.

samshers
  • 1
  • 6
  • 37
  • 84
  • 6
    it hooks into _internal_ details of `javac`. details that, I repeat, are _internal_. just like jdk-17 started to prohibit some things already, this will ultimately happen to Lombok too, imo. and the gap for Lombok is closing too, the first step towards that are `records`. – Eugene Sep 16 '21 at 03:51
  • Hi, as far as I know, lombok uses [ Java Agents](https://docs.oracle.com/javase/1.5.0/docs/api/java/lang/instrument/package-summary.html). Eclipse require install Lombok, because it have his own agent, and it need to be replaced. There is also other technology for adding code during compiling: https://docs.oracle.com/javase/6/docs/technotes/guides/apt/index.html – Grzegorz Sep 16 '21 at 09:50
  • In regular case (not IDE), if you have Lombok on classpath, the agent is changed to Lombok agent (2. this is why you don't need maven-compile stage for it), (1.) so ```mvn clean compile``` will add the code – Grzegorz Sep 16 '21 at 10:01

0 Answers0