4

I am trying to use lombok in my application which is based on spring boot and maven configuration.

I have added the dependency:

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

in my pom.xml. Also as I am using STS, I have installed Lombok into my sts by running the jar. I am able to use Lombok annotations and use the getters, setters, etc. but I am not able to see my generated classes/methods in target/generated-sources folder.

Is there a particular reason, why I am not able to see those generated classes and how STS or maven is able to use these generated classes/methods?

Can any one help me understand? And if possible how to view those generated classes/methods?

Note: My source code folder is still src/main/java only.

happytohelp
  • 305
  • 3
  • 14

2 Answers2

3

Your project compiled class files are located in the target/classes folder. This folder is not visible in the default view i.e., Package Explorer view. You need to enable the Navigator (now deprecated) view from Window -> Show View to see the contents of the target folder. Once done, your compiled classes will be visible in the target/classes folder according to your project package structure.

happytohelp
  • 305
  • 3
  • 14
dope
  • 303
  • 4
  • 14
  • so the class generated by lombok will also be available in the target/classes folder right? – happytohelp Dec 10 '20 at 21:49
  • Yes. And you can use a decompiler plugin to see the generated getter and setter method for your class fields. – dope Dec 10 '20 at 21:51
2

Lombok doesn't work by outputting source into target/generated-sources; that technique only allows adding new source files, not modifying the classes being compiled. Lombok instead works by hacking into the compiler internals and messing with the compilation process itself.

chrylis -cautiouslyoptimistic-
  • 75,269
  • 21
  • 115
  • 152