IntelliJ IDEA Lombok Not Working

Answered

I am having problems with Lombok. It seems like it is not recognising the library when I type "include lombok." it does not offer me the possible options but it appears in external libraries.

 

 

This is what I have done so far:

  1. Installed Lombok-Plugin (14.16) with the IDEA plugin tool
  2. Enable annotation processing
  3. Enable Lombok for this project in Other settings.
  4. Added Lombok-plugin.jar and patch in gobal libreries
  5. Added dependency in gradle 
    compile "org.projectlombok:lombok:1.14.16"

Intellij IDEA 2017 1.2

JDK 1.8

 

Can somebody help me?

 

9 comments
Comment actions Permalink

You either use Gradle to manage dependencies or manage them manually, not both, otherwise your manually added dependencies will be discarded.

Refresh the Gradle project in IntelliJ IDEA and make sure you see the required jars added to the module dependencies (https://www.jetbrains.com/help/idea/2017.1/working-with-module-dependencies.html), verify you can browse the jar under External Libraries in the Project View.

If the issue remains, please provide a sample project illustrating the problem and the exact steps to reproduce.

0
Comment actions Permalink

Serge, thank you for your answer.

I was adding the dependency on Gradle. I did manually add the libraries as a global library and then the jar files appear under dependencies in Modules, and they do appear in the External Libraries in the Project View. Before adding the libraries in import lombak.RequieredConstructor lombak was displayed red, and after adding the libraries it turned gray and now the next term (RequieredConstructor) appears red.

 



this is on gradle


plugins {
id 'java'
id 'org.springframework.boot' version '1.4.3.RELEASE'
}

repositories { mavenCentral()
}

group = "org.example" version = "1.0.0"

tasks.bootRun {
systemProperties System.properties
}

dependencies {
compile "org.projectlombok:lombok:1.14.16"
compile "org.springframework.boot:spring-boot-starter-web:1.4.3.RELEASE"
compile "org.springframework.boot:spring-boot-devtools:1.4.3.RELEASE"
compile "org.mock-server:mockserver-netty:3.10.4"
}
0
Comment actions Permalink

You do not have the correct dependency in the classpath. Please try this instead:

dependencies {
compileOnly "org.projectlombok:lombok:1.16.16"
}

repositories {
mavenCentral()
jcenter()
}

Using jcenter repository is important.

See also:

https://github.com/franzbecker/gradle-lombok
http://stackoverflow.com/questions/40475910/using-lombok-with-gradle-and-spring-boot

1
Comment actions Permalink

Problem solved!

It seems like I had, I don't know what is the function of it.

group = "org.example" version = "1.0.0"

I commented the line and it worked, I am doing a tutorial and I don't really understand how this works, will see if it affects that I commented that line.

Thank you Serge!

0
Comment actions Permalink

I don't have this problem with maven type project in Intellij.

Why it's happening always with gradle?

0
Comment actions Permalink

Serge Baranov Thanks a lot! it works for me!  

0
Comment actions Permalink

In my case, Intellij's Lombok plugin version was 1.18.10 where as; project's compile-only dependency was expecting version as 1.18.4.

Figured out after enabling the lombok warnings.

0
Comment actions Permalink

"this does not work out of the box"

0
Comment actions Permalink

lmdbluis what is the specific issue?

0

Please sign in to leave a comment.