Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Lombok in AEM

Avatar

Level 1

Hello Folks,

Can somebody help me how can Lombok be integrated into AEM project to avoid boilerplate code? Is there any documentation by Adobe? Appreciated if someone can gives with example please. 

Thanks!

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi @ahana_k ,

"Project Lombok is a java library that automatically plugs into your editor and build tools, spicing up your java.
Never write another getter or equals method again, with one annotation your class has a fully featured builder, Automate your logging variables, and much more."

For more details please read official documentation [0].

How can Lombok be implemented in AEM?

I haven't found any documentation from Adobe. However, there are plenty of un-official sites by visiting them you can understand how it works & how can it be implemented in AEM.

  • You can add “Lombok” in your maven project as maven dependency. To include lombok as a 'provided' dependency, add it to your <dependencies> block like so:

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

Here are some sites where you can see some practical along with examples [1], [2].

[0]: https://projectlombok.org/

[1]: https://blogs.perficient.com/2021/06/14/writing-less-java-code-in-aem-with-sling-models-lombok/

[2]: https://www.linkedin.com/pulse/code-generator-aem-sling-models-lombok-sandip-kumar/?trk=pulse-articl...

Hope that helps!

Regards,

Santosh

View solution in original post

1 Reply

Avatar

Correct answer by
Community Advisor

Hi @ahana_k ,

"Project Lombok is a java library that automatically plugs into your editor and build tools, spicing up your java.
Never write another getter or equals method again, with one annotation your class has a fully featured builder, Automate your logging variables, and much more."

For more details please read official documentation [0].

How can Lombok be implemented in AEM?

I haven't found any documentation from Adobe. However, there are plenty of un-official sites by visiting them you can understand how it works & how can it be implemented in AEM.

  • You can add “Lombok” in your maven project as maven dependency. To include lombok as a 'provided' dependency, add it to your <dependencies> block like so:

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

Here are some sites where you can see some practical along with examples [1], [2].

[0]: https://projectlombok.org/

[1]: https://blogs.perficient.com/2021/06/14/writing-less-java-code-in-aem-with-sling-models-lombok/

[2]: https://www.linkedin.com/pulse/code-generator-aem-sling-models-lombok-sandip-kumar/?trk=pulse-articl...

Hope that helps!

Regards,

Santosh