-1

I'm trying to introduce Lombok annotations into a Maven Java project in IntelliJ IDEA and followed the steps here and here.

@Data annotation (for one) is not being recognized:

enter image description here

enter image description here

Here's the relevant Maven stanza:

    <dependency>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
        <version>1.16.18</version>
    </dependency>
</dependencies>

I'm on Idea 2017.3.2 CE.

I tried the solution mentioned here, it doesn't work:

enter image description here

Doing File | Invalidate Caches & Restart didn't help.

What am I missing here?

Hovercraft Full Of Eels
  • 283,665
  • 25
  • 256
  • 373
Simeon Leyzerzon
  • 18,658
  • 9
  • 54
  • 82
  • Try to invalidate the cache. – Ele Dec 28 '17 at 22:38
  • What does it say when you enter annotation and move your mouse cursor over it ? – whatamidoingwithmylife Dec 28 '17 at 22:38
  • @EleazarEnrique how? – Simeon Leyzerzon Dec 28 '17 at 22:42
  • @GCP It says: 'Cannot resolve symbol @ Data'. It's not downloading the library, it's not in Maven repo or listed as Maven dependency in IDE. I'd assume that plugin would do it? – Simeon Leyzerzon Dec 28 '17 at 22:44
  • OK man, I just let it install automatically from repository like you did and it didn't work, so I just went to the website downloaded .jar from there and went to IntelliJ File -> Project Structure -> Click on Dependencies tab -> Select your lombok.jar -> Select lombok on the dependency list, click Apply and OK, go to your class add `Data` anotation and just let IntelliJ import lombok.Data by moving cursor to @Data and pressing Alt+Enter and choosing import option. Let me know if it works now. – whatamidoingwithmylife Dec 28 '17 at 23:01
  • @GCP: @ Data annotation is not among the dependencies there which I'm assuming why the whole setup doesn't work. I thought that installing the IntelliJ Lombok plugin installs and resolves all the dependencies. Apparently it's not the case. – Simeon Leyzerzon Dec 28 '17 at 23:22
  • Yea, after installing I still had to download and add .jar to Dependency list, and I still had some issues as I was using JDK 9 so I had to install JDK 8 as well and now it's working normally. – whatamidoingwithmylife Dec 28 '17 at 23:24
  • As it says in the question I linked to: Settings -> Compiler -> Annotation Processors -> Enable annotation processing (make sure this is checked) – ubadub Dec 29 '17 at 02:16
  • OK man, I see you posted it again, I'll try and make a real quick tutorial with pictures on what to do. Hope this one doesn't get closed before I finish :D – whatamidoingwithmylife Dec 29 '17 at 02:18
  • @SimeonLeyzerzon I didn't see the edits, sorry – ubadub Dec 29 '17 at 02:22

1 Answers1

4

What helped was going into File | Project structure and adding a library from Maven (via search for org.projectlombok there):

enter image description here

That downloaded the missing jar into the local repo which I assumed should have been done by the Lombok plugin.

Seems to be yet another IntelliJ Idea bug or at least a shortcoming not clearly mentioned in either Lombok or IntelliJ plugin documentation. I've opened an issue here, perhaps this will save some struggle to other developers in the meantime.

Simeon Leyzerzon
  • 18,658
  • 9
  • 54
  • 82
  • Also, if some people still have problems after setting everything up, make sure you are not using JDK 9 as it has some issues with this plugin at the moment. Use JDK 8. – whatamidoingwithmylife Dec 29 '17 at 02:22
  • 2
    Oh jeez, please don't tell you didn't refresh the project maven settings after updating the pom file which also loads the added dependencies. – Tom Dec 29 '17 at 03:23
  • @Tom: Well, I did do a project rebuild (Ctrl + F9) if that's what you are referring to. I also tried rebuilding with Maven from within IDEA. Or are there other requried steps that I might have missed? Shouldn't it pull the Maven changes when it discovers them in the pom.xml? It's smarter than Eclipse in sensing the updates in the file system, why can't it do the same for Maven deps? – Simeon Leyzerzon Dec 29 '17 at 03:28
  • 1
    It does if you set up your IDE to do that. If not, then it usually shows a popup that you need to re-import the maven file after changing it. And, no, a project rebuild is something different. – Tom Dec 29 '17 at 03:30