Maven Scope for Lombok (Compile vs. Provided) Maven Scope for Lombok (Compile vs. Provided) java java

Maven Scope for Lombok (Compile vs. Provided)


Lombok should be used at the provided scope (see the official docs).

The reason (as has been stated in the comments) is that lombok is a compile-time-only tool. That is, it is not needed at runtime at all. By making the scope provided, you make the lombok libraries available to the compiler but it is not a dependency of your compiled jar. As such, your final jar will not depend on Lombok and it does not need to be included in any deployment, which reduces the dependencies and size of your deployables.


Usually compile. provided is for jars that are usually shipped with the application server that will host the application. If you don't want the jar in the final application, it is maybe best to use the maven plugin rather than the jar directly: http://awhitford.github.io/lombok.maven/lombok-maven-plugin/index.html


One can work with compile and true for <optional/>.

<scope>compile</scope><optional>true</optional>

See Maven – Optional Dependencies and Dependency Exclusions.