Intellij does not recognize lombok.config when building
Asked Answered
M

2

10

I opened the restbucks project with Intellij. I have lombok plugin installed, annotation processing enabled. I am using javac compiler in Intellij settings. I have lombok.config in project root like in git repository, I also tried copying it to src/main/java and src/main/resources but no matter what I try, when I build the project with Intellij, after posting an order, I get:

Argument #0 of constructor [constructor for org.springsource.restbucks.order.Order, annotations: {interface com.fasterxml.jackson.annotation.JsonCreator=@com.fasterxml.jackson.annotation.JsonCreator(mode=DEFAULT)}] has no property name annotation; must have name when multiple-parameter constructor annotated as Creator

Seems like lombok.anyConstructor.suppressConstructorProperties=true has no effect. When I build with maven then it works fine. When I delete the lombok.config file, Intellij starts showing errors all over the project so the file seems to be recognized by Intellij afterall. But the build doesn't run as expected as posting to orders fails as mentioned above. Does anyone know what's going on here?

Mosque answered 13/11, 2017 at 9:1 Comment(0)
S
2

Lombok plugin does support lombok.config file.

The lombok.anyConstructor.suppressConstructorProperties is deprecated as per in Lombok doc

BREAKING CHANGE: lombok config key lombok.anyConstructor.suppressConstructorProperties is now deprecated and defaults to true, that is, by default lombok no longer automatically generates @ConstructorProperties annotations. New config key lombok.anyConstructor.addConstructorProperties now exist; set it to true if you want the old behavior. Oracle more or less broke this annotation with the release of JDK9, necessitating this breaking change.

Use the new lombok.anyConstructor.addConstructorProperties in the lombok.config located in the root folder and also, perform a clean install and then should be fine.

Seaway answered 9/12, 2019 at 19:10 Comment(1)
My new lombok.config did not work until I did a mvn clean install as shared by @flávio-henriqueQuire
P
2

My observation is that the lombok.config file has to be in src/main/java not src/main/resources for IntelliJ to pick it up.

Protist answered 14/10, 2023 at 4:48 Comment(2)
This saved my day! Indeed I was putting it in src/main/resources (since it's a resource...) and it was ignored! Moving it into src/main/java solved the problem!Konstance
That's the only working solution for me. I've been searching for this one for the last 2 weeks. Thank you tom!Doorpost

© 2022 - 2024 — McMap. All rights reserved.