What is the purpose of Spring Boot excluding Lombok plugin?

Viewed 247

I am aware what Lombok is - it minimizes boilerplate code through the use of some annotations.
And lombok generates the equivalent java code at compile time by using java internals [Ref]. Hence it does not need any explicit plugin or maven/gradle build phase during compile time.

On looking at the pom.xml of a Spring Boot Project, I see below plugins section and am wondering what this exclusion is about.

<build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <excludes>
                        <exclude>
                            <groupId>org.projectlombok</groupId>
                            <artifactId>lombok</artifactId>
                        </exclude>
                    </excludes>
                </configuration>
            </plugin>
        </plugins>
</build>
1 Answers

Well,

the problem is following: lombok is an annotation processor, and the code generated with/by lombok do not depend on lombok anymore, in maven terms that means dependency on lombok should has provided scope (in order to not include lombok jar into target artifact), unfortunately, spring guys have another opinion about dependencies with scope=provided, please check this conversation: Maven requires plugin version to be specified for the managed dependency spring-boot-configuration-processor

So, your configuration explicitly removes lombok jar from target artifact.

Related